1
votes

l'm working with networkX to generate hundred of random graphs of class :

complete_graph()
star_graph()
balanced_tree()
wheel_graph()
watts_strogatz_graph(n, 2, 0)

l set number of nodes n=100

for each class l get create 20 examples.

My question is as follow :

for i in numpy.arange(20):
    complete_graph=networkx.complete_graph(n)
    node_positions = networkx.spring_layout(G, scale=100)
    Adjacency = networkx.adjacency_matrix(G)

Do l get 20 different graphs in terms of adjacency matrix and nodes positions or for all the 20 graphs I get the same adjacency matrix and nodes positions?

1

1 Answers

0
votes

You get the same adjacency matrix each time you call complete_graph(n), namely the n by n matrix filled with 1. This, and other non-random graph constructions in NetworkX, yield the same result every time.

The layout methods are not deterministic, however. They involve an optimization process with a random starting point: first, place the vertices randomly, then move them to minimize a certain "energy" value. The resulting layout of a graph will be different for each invocation of spring_layout.