NETWORKX:
A graph theory and complex network modeling tool developed in Python language,
Built-in diagrams and complex network analysis algorithms that are often used
It can easily carry out complex network data analysis, simulation modeling and other work.
Dependent Tools :
NumPy
Pyparsing
Datautil
Matplotlib
Networkx
Make an experiment with random graphs:
From random import random, Choiceimport Networkx as Nximport Matplotlib.pyplot as Pltdef Dist (A, B): (x1, y1) = a (x2, y2) = B return ((X1-X2) * * 2 + (Y1-Y2) * * 2) * * 0.5G = NX. Graph () points = [(random (), random ()) for _ in range (8)]for p1, p2 in Zip (points[:-1], points[1:]): G.add_edge (P1, p 2, Weight=dist (P1, p2)) for _ in range (8): p1, p2 = choice (points), choice (points) G.add_edge (P1, p2, weight=dist (P1, p2)) Nx.draw (G) plt.savefig (' Asd.png ') plt.show ()
Make a complete picture of the experiment:
Import Networkx as Nximport matplotlib.pyplot as PLTG = Nx.complete_graph (6) Nx.draw (G) plt.savefig ("Asd.png") plt.show ()
Python Graph theory Tools