Statistics
| Branch: | Revision:

wcn_emulator / scripts / random_graph_generator.py @ b8b54c8f

History | View | Annotate | Download (493 Bytes)

1
#!/usr/bin/env python
2

    
3
import networkx as nx
4
import sys
5

    
6
if len(sys.argv) != 4:
7
    print "usage: ./random_graph_generator.py numGraphs prefix numNodes"
8
    sys.exit(1)
9

    
10
numGraphs = int(sys.argv[1])
11
prefix = sys.argv[2]
12
numNodes = int(sys.argv[3])
13

    
14
for i in range(numGraphs):
15
    g = nx.fast_gnp_random_graph(numNodes,0.5)
16
    if nx.is_connected(g):
17
        for e in g.edges(data=True):
18
            e[2]["weight"] = 1
19
        nx.write_edgelist(g, prefix+"-"+str(i)+".edges", data=["weight"])
20