mardi 24 février 2015

Efficient datastructure

What is the best data structure for the following problem?


a=["how","are","you"] b=["are","you","okay"]


given these two lists i want to construct a directed graph like


how->are->you->okay


Requirements



  1. I want to store a data in the nodes

  2. I want to assign a weight to the edges

  3. I want to find the data stored in node,given the key(eg 'how')

  4. I want to get the edge weight,given the nodes to which the edge is connected(eg given 'how' and 'are',I want to know the edge weight)


Aucun commentaire:

Enregistrer un commentaire