def core_results_to_cliques(r):
    """
    Given a list of clique patterns, return all cliques represented.
    :param r:
    :return:
    """
    return cg.core_results_to_cliques(r)
Example #2
0
def core_results_to_cliques(r):
    """
    Given a list of clique patterns, return all cliques represented.
    :param r:
    :return:
    """
    return cg.core_results_to_cliques(r)
Example #3
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
def compare_maximal(g):
    """
    Given the graph g, run the networkX version of finding all maximal cliques,
    and our version, and compare the sets. Fail if any are different.
    :param g: graph in networkx format
    :return: success flag
    """
    nwx_results = nx_answer(g)
    print(len(nwx_results), " expected maximal cliques for ", str(g))
    print("correct: ", nwx_results)

    our_results = [set(x) for x in cg.core_results_to_cliques( ca.process_from_g(g) )]
    our_results = rem_subsets(our_results)

    print("ours: ", our_results)
    if not same_results(nwx_results, our_results):
        return False
    return True
Example #5
0
def compare_maximal(g):
    """
    Given the graph g, run the networkX version of finding all maximal cliques,
    and our version, and compare the sets. Fail if any are different.
    :param g: graph in networkx format
    :return: success flag
    """
    nwx_results = nx_answer(g)
    print(len(nwx_results), " expected maximal cliques for ", str(g))
    print("correct: ", nwx_results)

    our_results = [
        set(x) for x in cg.core_results_to_cliques(ca.process_from_g(g))
    ]
    our_results = rem_subsets(our_results)

    print("ours: ", our_results)
    if not same_results(nwx_results, our_results):
        return False
    return True
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