'How can I store information of an edge with Python Networkx

I converted a dictionary into a graph using NetworkX. Apart from just information about source and destination of an edge, the dictionary contains metadata of that edge like a name of that edge and a probability value related to that edge. Also the graph contains parallel edges. This is the first first two key value pairs for first two keys of the dictionary. You can notice there are two parallel edges between the nodes 25255942 and 72359602 with different names and probabilities.

{25255942: {52691892: [('Internet of Things (IOT) Device Management',
    0.4444444444444444)],
  72359602: [('Internet of Things (IOT) Device Management', 1.0),
   ('Questions', 0.07692307692307693)]},
 185589766: {183701781: [('"Cloud Computing" How to use it for your business',
    0.4),
   ('Learn How to Be a Success in Network Marketing', 0.16666666666666666)],
  183702935: [('"Cloud Computing" How to use it for your business', 0.4),
   ('Learn How to Be a Success in Network Marketing', 0.16666666666666666)],
  110069642: [('Learn How to Be a Success in Network Marketing',
    0.3333333333333333),
   ('How to make money in network marketing', 1.0)]}}

If I simply convert this dictionary into a graph and print the edges by this command g.edges() it looks like below, I mean, loses the metadata and the information regarding parallel edges too.

[(25255942, 52691892), (25255942, 72359602), .....]

Is there a way to create a graph using NetworkX without losing any information?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source