def synthetic(): b = open('synthetic.csv', 'w') a = csv.writer(b) data = [["Data", "k=1", "k=5", "k=25", "k=100"]] for file_name in ("web-Stanford.txt", "ca-AstroPh.txt", "soc-LiveJournal1.txt", "cit-Patents.txt"): file = os.path.dirname( os.path.abspath(__file__)) + '/graphs/' + file_name G1 = BuildGraphFromFile(file) neighbors_dic = InitNeighbors(G1) times = [] times.append(file_name) for i in (1, 5, 25, 100): prunconnected.k = i time = prunconnected.run(G1, 1000, neighbors_dic, "")[0] times.append(time) data.append(times) G1 = BuildGraphFromFiles("./graphs/twitter") neighbors_dic = InitNeighbors(G1) times = [] times.append("twitter") for i in (1, 5, 25, 100): prun2.k = i time = prun2.run(G1, 1000, neighbors_dic, "") times.append(time) data.append(times) a.writerows(data) b.close() pretty_file.pretty_file("synthetic.csv", header=True, border=True, delimiter=",", new_filename="synthetic.txt")
def differentNumberOfResultsWithAllTypes(): b = open('diffrent_number_of_results_for_all_types.csv', 'w') a = csv.writer(b) data = [[ "Number of results", "EnumIncExcConnected", "EnumConnected", "EnumIncExcUnConnected", "EnumUnConnected" ]] print "Building a random graph with 1000000 nodes and 10000000 edges." G1 = snap.GenRndGnm(snap.PUNGraph, 1000000, 10 * 1000000) neighbors_dic = InitNeighbors(G1) for i in (1, 10, 100, 1000, 10000): times = [] num_of_nodes = 1000000 prunconnected.k = 5 time1 = prunconnected.run(G1, i, neighbors_dic, "")[0] noprun.k = 5 time2 = noprun.run(G1, i, neighbors_dic) prun2.k = 5 time3 = prun2.run(G1, i, neighbors_dic, "") noprun.k = 5 time4 = noprun.run(G1, i, neighbors_dic) data.append([i, time1, time2, time3, time4]) a.writerows(data) b.close() pretty_file.pretty_file( "diffrent_number_of_results_for_all_types.csv", header=True, border=True, delimiter=",", new_filename="diffrent_number_of_results_for_all_types.txt")
def differentNumberOfNodesEnumIncExc(): b = open('diffrent_number_of_nodes.csv', 'w') a = csv.writer(b) data = [["Number of nodes", "EnumIncExc"]] for i in (1, 10, 100, 1000): times = [] num_of_nodes = i * 1000 times.append(num_of_nodes) print "Building a random graph with %s nodes and %s edges." % ( num_of_nodes, 10 * num_of_nodes) G1 = snap.GenRndGnm(snap.PUNGraph, num_of_nodes, 10 * num_of_nodes) neighbors_dic = InitNeighbors(G1) prunconnected.k = 5 time = prunconnected.run(G1, 1000, neighbors_dic, "")[0] times.append(time) data.append(times) a.writerows(data) b.close() pretty_file.pretty_file("diffrent_number_of_nodes.csv", header=True, border=True, delimiter=",", new_filename="diffrent_number_of_nodes.txt") print "Results can be found in: diffrent_number_of_nodes.csv"
def find_kplex(G1): import prunning neighbors_dic = InitNeighbors(G1) print "Graph is ready" if (args.type == "unconnected" or args.type == "all"): prunning.k = args.k prunning.run(G1, args.num_of_kplex, neighbors_dic, args.output + "_unconnected") if (args.type == "connected" or args.type == "all"): prunconnected.k = args.k result = prunconnected.run(G1, args.num_of_kplex, neighbors_dic, args.output + "_connected")
def differentNumberOfEdgesEnumIncExc(): b = open('diffrent_number_of_edges.csv', 'w') a = csv.writer(b) data = [["Number of edges", "EnumIncExc"]] for i in (1000, 10000, 100000): times = [] num_of_edges = i * 1000 print "Building a random graph with 1000000 nodes and %s edges." % num_of_edges G1 = snap.GenRndGnm(snap.PUNGraph, 1000000, num_of_edges) neighbors_dic = InitNeighbors(G1) print "Graph is ready" prunconnected.k = 5 time1 = prunconnected.run(G1, 1000, neighbors_dic, "")[0] data.append([num_of_edges, time1]) a.writerows(data) b.close() pretty_file.pretty_file("diffrent_number_of_edges.csv", header=True, border=True, delimiter=",", new_filename="diffrent_number_of_edges.txt")
def differentNumberOfKEnumIncExc(): import noprun #import noprunun2 b = open('diffrent_number_of_k.csv', 'w') a = csv.writer(b) data = [["k", "EnumIncExc"]] print "Building a random graph with 1000000 nodes and 10000000 edges." G1 = snap.GenRndGnm(snap.PUNGraph, 1000000, 10 * 1000000) neighbors_dic = InitNeighbors(G1) for i in (1, 5, 25, 100): times = [] num_of_nodes = 1000000 prunconnected.k = i time1 = prunconnected.run(G1, 1000, neighbors_dic, "")[0] data.append(["k = %s" % i, time1]) a.writerows(data) b.close() pretty_file.pretty_file("diffrent_number_of_k.csv", header=True, border=True, delimiter=",", new_filename="diffrent_number_of_k.txt")