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 differentNumberOfResultsEnumNotConnected():
    b = open('differentNumberOfResultsEnumNotConnected.csv', 'w')
    a = csv.writer(b)
    data = [["Number of results", "EnumNotConnected"]]
    print "Building a random graph with 1000000 nodes and 10000000 edges."
    G1 = snap.GenRndGnm(snap.PUNGraph, 1000000, 10 * 1000000)
    neighbors_dic = InitNeighbors(G1)
    num_of_nodes = 1000000
    noprun.k = 5
    time2 = noprun.run(G1, 10000, neighbors_dic)
    print "%f" % time2
    time2 = 0
    for i in (1, 10, 100, 1000, 10000):
        times = []
        num_of_nodes = 1000000
        noprun.k = 5
        time2 = noprun.run(G1, i, neighbors_dic)

        data.append([i, time2])
    a.writerows(data)
    b.close()
    pretty_file.pretty_file(
        "differentNumberOfResultsEnumNotConnected.csv",
        header=True,
        border=True,
        delimiter=",",
        new_filename="differentNumberOfResultsEnumNotConnected.txt")
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"):
        if args.mode == "EnumIncExc":
            prunconnected.k = args.k
            result = prunconnected.run(G1, args.num_of_kplex, neighbors_dic,
                                       args.output + "_connected")
        if args.mode == "Enum":
            noprun.k = args.k
            noprun.run(G1, args.num_of_kplex, neighbors_dic)
def differentNumberOfNodesEnum():
    b = open('diffrent_number_of_nodes.csv', 'w')
    a = csv.writer(b)
    data = [["Number of nodes", "EnumIncExc"]]
    for i in (1, 10, 100, 1000, 10000):
        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)

        noprun.k = 5
        time = noprun.run(G1, 1000, neighbors_dic)
        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 differentNumberOfEdgesEnum():
    b = open('diffrent_number_of_edges.csv', 'w')
    a = csv.writer(b)
    data = [["Number of edges", "Enum"]]
    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"
        noprun.k = 5
        time2 = noprun.run(G1, 10000, neighbors_dic)
        data.append([num_of_edges, time2])
    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 differentNumberOfKEnum():
    import noprun
    #import noprunun2
    b = open('diffrent_number_of_k.csv', 'w')
    a = csv.writer(b)
    data = [["k", "Enum"]]
    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

        noprun.k = i
        time2 = noprun.run(G1, 1000, neighbors_dic)
        data.append(["k = %s" % i, time2])
    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")