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() print 'output Graph (possibly disconnected):' print 'nodes = %d' % graph.number_of_nodes() print 'edges = %d' % graph.number_of_edges() print 'connected components fractions: %s' % str(comps) digraph.erase_from_disk()
filename = len(sys.argv) > 1 and sys.argv[1] or None if not filename: #filename = 'orkut-links-fst.txt.toundirected.30mill' print 'Error: first argument missing, input filename with space separated graph!' exit(-1) outname = len(sys.argv) > 2 and sys.argv[2] or None if not outname: #outname = 'orkut-2k_sym.big_graph' print 'Error: second argument missing, output filename!' exit(-1) graphfile = filename graph = BigGraph(graphfile) graph.debug = True graph.input_debug_links = 200000 graph.output_debug_nodes = 10000 print 'NODES:' print graph.number_of_nodes() print 'EDGES:' print graph.number_of_edges() print 'dumping Graph to edge list file ...' graph.save_edgelist(outname) print 'done.'
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()