def _assert_fractionally_isomorphic(G=None, H=None, algorithm='cep'): if G is None: G = graph_from_file('data/graph1.txt') if H is None: H = graph_from_file('data/graph2.txt') are_isomorphic, S = are_fractionally_isomorphic(G, H, algorithm=algorithm) assert are_isomorphic if algorithm == 'cep': partition1, partition2 = S assert is_valid_partition(G, partition1) assert is_valid_partition(H, partition2) assert is_partition_equitable(G, partition1) assert is_partition_equitable(H, partition2) assert are_common_partitions(G, partition1, H, partition2) else: assert verify_isomorphism(G, H, S)
def _cep_solver(G, H): """Solves the fractional graph isomorphism problem by comparing the coarsest equitable partitions of G and H. Returns a two-tuple whose left element is a Boolean representing whether the two graphs have a common coarsest partition and whose right element is the pair of partitions of the given graphs (in the same order as the inputs are given). If the left element is ``False``, the right element is ``None``, since there is no witness that the graphs are fractionally isomorphic. """ partition1 = coarsest_equitable_partition(G) partition2 = coarsest_equitable_partition(H) result = are_common_partitions(G, partition1, H, partition2) witness = (partition1, partition2) if result else None return result, witness