Home > Net >  Generate Network Graph in Python from nested dictionary
Generate Network Graph in Python from nested dictionary

Time:04-30

I have an input dictionary like:

d={'node1':{'node1_1':1.2,'node1_2':1.3,'node1_3':1.2},'node2': 
           {'node2_1':1.3,'node2_2':1.3,'node2_3':1.4}}

In the output, node1 has a relationship with node1_1 with a weight of 1.2, node1_2 with a weight of 1.3, and node 1-3 with a weight of 1.2. The same is the case for node2 it links with node 2_1,node2_2, and node2_3 along with their respective weights. Is there any generalized way to generate a directed graph from the input dictionary using NetworkKx or through any other way in Python?

CodePudding user response:

IIUC, you can use nextworkx graph

  • Related