Networkx - graph & egdes attributes from csv file

68 views Asked by At

First, my apologies because I think this question has been asked previously in other way. I am just starting with Python (again...) and I am not familiar with all packages functionalities and reading codes Here below is the basic code I want to start with but each time I try to add a specific detail, I fail.

import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
data = pd.read_csv(r"C:\Users\n.philip\Documents\test_mine.csv",sep=";")
G=nx.from_pandas_edgelist(data, source='from', target='to',edge_attr=True)
nx.draw_networkx(G, with_labels=True, node_color='Green',node_size=40, linewidths=10)
nx.draw_networkx_edges(G, pos)
plt.show()

my template is like this :

from to edge_attr_1_number
A B 2
A C 6
A E 6
B A 4
B C 8
B D 4
B E 7
C A 7
C B 6
C D 3
C E 9
D A 9
D B 3
D C 1
D E 3
E A 5

enter image description here

My question is : how to exploit the column "edge_attributes_1" which is an integer to use it as a value for the relative thickness of the edge and while summed (the attribute is an integer) as the relative size of the nodes

I am afraid I mixe "propertie" of package which make my tries go wrong. A true thank for your precious help

0

There are 0 answers