def test_balanced_tree_initial_partition(): graph = nx.balanced_tree(2, 3, create_using=nx.DiGraph) initial_partition = [ (0, 1, 2), (3, 4), (5, 6), (7, 8, 9, 10), (11, 12, 13), (14, ), ] assert to_set( dovier_piazza_policriti( graph, initial_partition=initial_partition)) == to_set( paige_tarjan(graph, initial_partition=initial_partition))
def test_incremental_update_rscp_correctness(goal_graph, initial_partition): initial_graph = nx.DiGraph() initial_graph.add_nodes_from(goal_graph.nodes) partition = saha_partition(initial_graph, initial_partition) edges = [] for edge in goal_graph.edges: edges.append(edge) g = nx.DiGraph() g.add_nodes_from(goal_graph.nodes) g.add_edges_from(edges) # compute its rscp rscp = set( map( frozenset, paige_tarjan(g, initial_partition, is_integer_graph=True), )) # compute the rscp incrementally rscp2 = partition.add_edge(edge) assert to_set(rscp2) == rscp
def test_dpp_correctness_all_scc_leaf_with_initial_partition(): graph = nx.DiGraph() graph.add_nodes_from(range(3)) graph.add_edges_from([(0, 1), (1, 2), (2, 0)]) assert to_set(dovier_piazza_policriti(graph, [(0, 1), (2, )])) == set( [frozenset([0]), frozenset([1]), frozenset([2])])
def test_add_edges(): graph = nx.balanced_tree(2, 3, create_using=nx.DiGraph) partition = saha_partition(graph) edges = [(1, 0), (8, 1)] new_graph = nx.balanced_tree(2, 3, create_using=nx.DiGraph) new_graph.add_nodes_from(range(len(graph.nodes))) new_graph.add_edges_from(graph.edges) new_graph.add_edges_from(edges) assert to_set(paige_tarjan(new_graph)) == set( map(frozenset, partition.add_edges(edges)))
def test_compute(): graph = nx.balanced_tree(2, 3, create_using=nx.DiGraph) initial_partition = [ (0, 1, 2), (3, 4), (5, 6), (7, 8, 9, 10), (11, 12, 13), (14,) ] assert to_set(compute_maximum_bisimulation( graph, initial_partition )) == to_set(paige_tarjan(graph, initial_partition)) assert to_set(compute_maximum_bisimulation( graph, initial_partition, algorithm=Algorithms.DovierPiazzaPolicriti )) == to_set(paige_tarjan(graph, initial_partition)) assert to_set(compute_maximum_bisimulation( graph, initial_partition, algorithm=Algorithms.PaigeTarjan )) == to_set(paige_tarjan(graph, initial_partition))
def test_dpp_default_trivial_partition(): graph = nx.balanced_tree(2, 3, create_using=nx.DiGraph) assert to_set( dovier_piazza_policriti(graph, [tuple(range(len(graph.nodes)))])) == to_set( dovier_piazza_policriti(graph))
def test_dpp_correctness2(graph): assert to_set(dovier_piazza_policriti(graph)) == to_set( paige_tarjan(graph))
def test_dpp_rscp_correctness(graph, initial_partition, expected_q_partition): assert to_set(dovier_piazza_policriti(graph, initial_partition)) == to_set( paige_tarjan(graph, initial_partition))