Note that you're linking the networkx documentation of version 1.6 whereas the current version is 1.8.1.
I recommend rather thinking about what type of graph you need, i.e., single undirected edges between your nodes, choose a networkx.Graph
, multiple directed edges, choose a networkx.MultiDiGraph
(DiGraph
and MultiGraph
also exist).
You can then use the add_edge
or add_edges_from
methods and they will generate the underlying data structure for you, for example,
>>> import networkx as nx
>>> net = nx.Graph()
>>> net.add_edge("user_42", "user_9", trust=9)
>>> net.adj
{'user_42': {'user_9': {'trust': 9}}, 'user_9': {'user_42': {'trust': 9}}}