pythonnetworkxcomplex-networks

Draw a weighted complex network with NetworkX


Can the package NetworkX be used to draw complex network with weights given by a distribution, for example a power law? Then can I write a code to draw the weight distribution or strength distribution, or even further to draw the weighted average nearest neighbours degree of a node? then coloring each class of similar degrees, or similar strenghs, etc.

I have a large data of a complex network consisting of about 300 nodes, and data about individual egdes' weights. What is the best way to draw such a network?


Solution

  • Edges in networkx can use the special attribute 'weight' which can be used in a number of algorithms requiring weighted edges. You can use networkx drawing commands to take these weights into account (e.g., by the spring force in a spring embedded visualisation). Something like:

    >>> import networkx as nx
    >>> import matplotlib.pyplot as plt
    >>> G = nx.Graph()
    >>> # add nodes, edges, etc.
    ...
    >>> nx.draw_spring(G)
    >>> plt.show()