0
votes

I would like to make a directed graph out of the following:

  • List of stimuli words (list of strings) that have out-edges
  • List of dictionaries corresponding to each stimuli word containing: key=response-words and value, where value is frequency of response, so edges between stimuli word and response word have the frequency as their weight

Is there a way to create a graph out of this information using networkX without creating nodes separately and giving them integer values (so instead we create the node directly with the key/string rather than labelling the nodes that already have integer values)?

1

1 Answers

0
votes

Try it?

In [1]: import networkx as nx

In [2]: G = nx.DiGraph()

In [3]: G.add_edge('dog','cat',frequency=7)

In [4]: G.edges(data=True)
Out[4]: [('dog', 'cat', {'frequency': 7})]