Monday, 12 August 2013

add_edges_from three tuples networkx

add_edges_from three tuples networkx

I am trying to use networkx to create a DiGraph. I want to use
add_edges_from(), and I want the edges and their data to be generated from
3 tuples.
I am importing the data from a csv file. I have three columns: one for
ids(first set of nodes), one for a set of names(second set of nodes) and
another for capacities (no headers in the file). So, I created a
dictionary for the ids and capacities.
dictionary = dict(zip(id, capacity))
then I zipped the tuples containing the edges data:
List = zip(id, name, capacity)
but when I execute the next line, it gives me an assertion error.
G.add_edges_from(List, 'weight': 1)
Can someone help me with this problem? I have been trying for a week with
no luck.
P.S. I'm a newbie in programming.

No comments:

Post a Comment