Networkx – graph & egdes attributes from csv file

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

  • This is not a graph problem. Please read tag descriptions before adding.

    – 

  • You need to tag with your language – python.

    – 

  • Template? Do you mean input? Question title says CSV but your ‘template’ is NOT CSV

    – 




  • thanks, I have added python and deleted “graph”.. yes the file is a csv but when pasting the initial table it has appeared all in line which confused me : didn t find the upload button. yes you can consider it as input. the script does retrieve the data, my point is about adding specific attributes to nodes and manipulate edges..

    – 




  • Since your are confused by your own question, imagine how other people feel. Edit your question to fix the problems.

    – 

Leave a Comment