Esempio n. 1
0
digraph.max_links_input = links
digraph.max_nodes_analysis = 10000

print 'digraph.load_edgelist(open(filename)) ...'
digraph.load_edgelist(open(filename))

print 'digraph.create_indices() ...'
digraph.create_indices()

graph = BigGraph(graphfile + '.disconnected')

print 'digraph.add_only_symmetric_edgelist(graph) ...'
digraph.add_only_symmetric_edgelist(graph)

print 'graph.create_indices() ...'
graph.create_indices()

number_of_nodes = graph.number_of_nodes()
comps = [
    len(comp) / float(number_of_nodes)
    for comp in graph.connected_components()
]

if comps[0] < 0.5:
    print 'ERROR: biggest connected componnet not found!'
    exit(-1)

print 'input DiGraph:'
print 'nodes = %d' % digraph.number_of_nodes()
print 'edges = %d' % digraph.number_of_edges()
Esempio n. 2
0
if not outname:
    print 'Error: second argument missing, output filename for BigGraph!'
    exit(-1)

graph = BigGraph(filename)
#graph = BigGraph()

#graph.add_edge(1,2)
#graph.add_edge(2,3)
#graph.add_edge(3,1)

#graph.add_edge(4,5)

aux_graph = Graph()
connected_graph = BigGraph(outname)

graph.add_random_component(aux_graph)

for src, dst in aux_graph.edges_iter():
    connected_graph.add_edge(src, dst)

connected_graph.create_indices()

print 'input Graph:'
print 'nodes = %d' % graph.number_of_nodes()
print 'edges = %d' % graph.number_of_edges()

print 'output connected Graph:'
print 'nodes = %d' % connected_graph.number_of_nodes()
print 'edges = %d' % connected_graph.number_of_edges()