My graph seems not correctly showing edge attributes (they should assign a weight to the edge). Also, I am getting the following error when I try to associate node's size with their degree.
An example of data is:
Node1 Node2 Edge_Weight Number
A B 0.2 1
A D 0.4 1
A N 0.1 1
B C 0.5 1
B A 0.3 1
S X 0.2 1
B N 0.1 2
S C 0.5 2
N A 0.3 2
S X 0.2 2
What I have done so far is defining a function that goes through the two files as follows:
def loop_func(df):
node_list=[]
G = nx.from_pandas_edgelist(file, source='Node1', target='Node2', edge_attr='Edge_Weight')
d = nx.degree(G)
for x in (df.Number.unique()):
df_num = df[df['Number'] == x]
graphs = [nx.from_pandas_edgelist(df_num, source='Node1', target='Node2', edge_attr='Edge_Weight') for _ in df.Number.unique()]
nx.draw_networkx(graphs[x-1])
plt.show()
This code generates the error: AttributeError: 'DegreeView' object has no attribute 'keys' . For sure there is something wrong in assign degree to nodes.