Python & NetworkX for Network Topology Data

I tried thousands of times to apply "NetworkX" Python library to analyze the datasets found by this link:

http://konect.uni-koblenz.de/networks/topology

As long as I execute my Python code to the data found there I got, for example, some unrealistic results.

g = nx.read_weighted_edgelist('out.topology')
g.size()
0

0 as a result for this huge data is completely wrong !

Could you please help me to read this data through "NetworkX" Python library ?

1 answer

  • answered 2017-11-15 00:37 rodgdor

    As someone mentioned trying reading the list gets errors. However, if you get rid of the first line (% sym positive) and try the code below to create your graph it should be fine:

    import networkx as nx
    
    with open("out.topology", 'rt') as f:
        g = nx.parse_edgelist(f, create_using=nx.DiGraph(), data=[('weight', float), ('timestamp', float)])
    

    The data contains 4 columns: source | target | weight | timestamp of edge.

    Just include that info in the arguments as shown in my snippet.