def test_folder(folder, perms=False):
    """
    Test if all DIMACS formatted graphs in a file are correctly analyzed by DESC,
    as compared to standard clique finding algorithm.
    :param folder:
    :param perms: Flag indicating whether to test all permutations of the graphs.
    :return: Success indicator.
    """
    files = os.listdir(folder)
    if '.DS_Store' in files:
        files.remove('.DS_Store')
    success = True
    for f in files:
        full_name = folder + f
        if perms:
            if not test_permutations(full_name):
                print(f, " failed")
                success = False
            else:
                print(f, " succeeded")
        else:
            g = graph_manip.create_networkx_graph(full_name)
            if not compare_maximal(g):
                print(f, " failed")
                success = False
            else:
                print(f, " succeeded")
    return success
Example #2
0
def test_permutations(filename):
    adj = ca.process_graph_file(filename)
    adj_perms = graph_manip.all_permutations(adj)
    print(filename, len(adj_perms))
    if len(adj_perms) > 10000:
        print("more than 10K perms! Just test basic", len(adj_perms), filename)
        g = graph_manip.create_networkx_graph(filename)
        if not compare_maximal(g):
            print(filename, " failed")
            return False
        return True
    for p in adj_perms:
        this_g = graph_manip.convert_to_nx(p)
        nwx_results = [
            set(x) for x in list(nx.algorithms.clique.find_cliques(this_g))
        ]

        this_res = ca.processing_steps(p)
        our_results = [set(x) for x in cg.core_results_to_cliques(this_res)]
        our_results = rem_subsets(our_results)
        if not same_results(nwx_results, our_results):
            print("adj failed", p)
            print(graph_manip.pretty_print(p))
            return False
    return True
Example #3
0
def test_folder(folder, perms=False):
    """
    Test if all DIMACS formatted graphs in a file are correctly analyzed by DESC,
    as compared to standard clique finding algorithm.
    :param folder:
    :param perms: Flag indicating whether to test all permutations of the graphs.
    :return: Success indicator.
    """
    files = os.listdir(folder)
    if '.DS_Store' in files:
        files.remove('.DS_Store')
    success = True
    for f in files:
        full_name = folder + f
        if perms:
            if not test_permutations(full_name):
                print(f, " failed")
                success = False
            else:
                print(f, " succeeded")
        else:
            g = graph_manip.create_networkx_graph(full_name)
            if not compare_maximal(g):
                print(f, " failed")
                success = False
            else:
                print(f, " succeeded")
    return success
def time_compare(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        nx.algorithms.clique.find_cliques(g)
    print("nx elapsed: %s", t.secs)
    with Timer() as t:
        ca.process_from_g(g)
    print("DESC elapsed: %s", t.secs)
Example #5
0
def time_compare(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        nx.algorithms.clique.find_cliques(g)
    print("nx elapsed: %s", t.secs)
    with Timer() as t:
        ca.process_from_g(g)
    print("DESC elapsed: %s", t.secs)
def time_nx(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        res = nx.algorithms.clique.find_cliques(g)
    print("nx elapsed: %s", t.secs)
    show = False
    if show:
        print("cliques:")
        for x in res:
            print(x)
Example #7
0
def time_nx(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        res = nx.algorithms.clique.find_cliques(g)
    print("nx elapsed: %s", t.secs)
    show = False
    if show:
        print("cliques:")
        for x in res:
            print(x)
def test_permutations(filename):
    adj = ca.process_graph_file(filename)
    adj_perms = graph_manip.all_permutations(adj)
    print(filename, len(adj_perms))
    if len(adj_perms) > 10000:
        print("more than 10K perms! Just test basic", len(adj_perms), filename)
        g = graph_manip.create_networkx_graph(filename)
        if not compare_maximal(g):
            print(filename, " failed")
            return False
        return True
    for p in adj_perms:
        this_g = graph_manip.convert_to_nx(p)
        nwx_results = [set(x) for x in list(nx.algorithms.clique.find_cliques(this_g))]

        this_res = ca.processing_steps(p)
        our_results = [set(x) for x in cg.core_results_to_cliques(this_res)]
        our_results = rem_subsets(our_results)
        if not same_results(nwx_results, our_results):
            print("adj failed", p)
            print(graph_manip.pretty_print(p))
            return False
    return True
def nx_answer_from_file(filename):
    g = graph_manip.create_networkx_graph(filename)
    return nx_answer(g)
def basic_check(filename):
    g = graph_manip.create_networkx_graph(filename)

    return compare_maximal(g)
def time_ours(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        res = ca.process_from_g(g)
    print(res)
    print("DESC elapsed: ", t.secs)
Example #12
0
def nx_answer_from_file(filename):
    g = graph_manip.create_networkx_graph(filename)
    return nx_answer(g)
Example #13
0
def basic_check(filename):
    g = graph_manip.create_networkx_graph(filename)

    return compare_maximal(g)
Example #14
0
def time_ours(filename):
    g = graph_manip.create_networkx_graph(filename)
    with Timer() as t:
        res = ca.process_from_g(g)
    print(res)
    print("DESC elapsed: ", t.secs)