Exemple #1
0
def test_comparisons():
    """Tests comparison operations between graphs.
    """
    # __eq__ and equals
    for directed in [True, False]:
        for static1 in [True, False]:
            for static2 in [True, False]:
                g1 = cg.graph(static=static1,
                              directed=directed,
                              vertices=list(range(3)))
                g2 = cg.graph(static=static2,
                              directed=directed,
                              vertices=list(range(3)))
                with pytest.raises(ValueError):
                    g1 == g2
                    g2 == g1
                assert g1.equals(g2)
                assert g2.equals(g1)
                g1.add_edge(0, 1)
                assert not g1.equals(g2)
                assert not g2.equals(g1)
                g2.add_edge(0, 1)
                assert g1.equals(g2)
                assert g2.equals(g1)
                g1.set_edge_attribute((0, 1), key="Attribute", val=True)
                assert not g1.equals(g2, edge_attrs=True)
                assert not g2.equals(g1, edge_attrs=True)
                g1.set_vertex_attribute(0, key="Attribute", val=True)
                assert not g1.equals(g2, vertex_attrs=True)
                assert not g2.equals(g1, vertex_attrs=True)
Exemple #2
0
def test_get_shortest_path_dijkstra():
    """Tests get_shortest_path_dijkstra function.
    """
    for static in [True, False]:

        undirected_graph = cg.graph(static=static,
                                    directed=False,
                                    vertices=[
                                        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                                        'i', 'j', 'k', 'l', 's'
                                    ])
        undirected_graph_edges = [('s', 'a', 7.0), ('s', 'b', 2.0),
                                  ('s', 'c', 3.0), ('a', 'b', 3.0),
                                  ('a', 'd', 4.0), ('b', 'h', 4.0),
                                  ('b', 'd', 1.0), ('c', 'l', 2.0),
                                  ('d', 'f', 5.0), ('l', 'i', 4.0),
                                  ('l', 'j', 4.0), ('i', 'k', 4.0),
                                  ('i', 'j', 6.0), ('j', 'k', 4.0),
                                  ('k', 'e', 5.0), ('f', 'h', 3.0),
                                  ('h', 'g', 2.0), ('g', 'e', 2.0)]
        for edge in undirected_graph_edges:
            undirected_graph.add_edge(*edge)

        undirected_path = alg.get_shortest_path_dijkstra(
            undirected_graph, 's', 'e')
        assert undirected_path == ['s', 'b', 'h', 'g', 'e']
        with pytest.raises(ValueError):
            alg.get_shortest_path_dijkstra(undirected_graph, 'y', 'z')

        disconnected_undirected_graph = cg.graph(static=static,
                                                 directed=False,
                                                 vertices=['a', 'b'])
        with pytest.raises(ValueError):
            alg.get_shortest_path_dijkstra(disconnected_undirected_graph, 'a',
                                           'b')

        directed_graph = cg.graph(
            static=static,
            directed=True,
            vertices=['s', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
        directed_graph_edges = [('s', 'a', 2.0), ('a', 'e', 3.0),
                                ('e', 'h', 4.0), ('h', 'g', 1.0),
                                ('h', 'e', 2.0), ('g', 'd', 2.0),
                                ('d', 's', 20.0), ('e', 'b', 1.0),
                                ('e', 'g', 6.0), ('b', 'c', 7.0),
                                ('c', 'f', 5.0), ('f', 'b', 0.0)]
        for edge in directed_graph_edges:
            directed_graph.add_edge(*edge)

        directed_path = alg.get_shortest_path_dijkstra(directed_graph, 's',
                                                       'e')
        assert directed_path == ['s', 'a', 'e']

        disconnected_directed_graph = cg.graph(static=static,
                                               directed=True,
                                               vertices=['a', 'b'])
        disconnected_directed_graph.add_edge('a', 'b')
        with pytest.raises(ValueError):
            alg.get_shortest_path_dijkstra(disconnected_directed_graph, 'b',
                                           'a')
Exemple #3
0
def test_partition_karger():
    """
    Tests partition_karger function.
    """
    sample_vertices = list(range(1, 6))
    sample_edges = list(itertools.combinations(sample_vertices, 2))
    sample_graphs = {
        'static': {
            'undirected':
            cg.graph(static=True, directed=False, vertices=sample_vertices),
            'directed':
            cg.graph(static=True, directed=True, vertices=sample_vertices)
        },
        'dynamic': {
            'undirected':
            cg.graph(static=False, directed=False, vertices=sample_vertices),
            'directed':
            cg.graph(static=False, directed=True, vertices=sample_vertices)
        }
    }
    for graph in [g for s in sample_graphs for g in sample_graphs[s].values()]:
        for edge in sample_edges:
            if not graph.has_edge(*edge):
                graph.add_edge(*edge)
    for static in sample_graphs:
        g2 = cg.graph(static=(static == 'static'), directed=False, vertices=[])
        with pytest.raises(ValueError):
            alg.partition_karger(g2)
        g2.add_vertex(1)
        with pytest.raises(ValueError):
            alg.partition_karger(g2)

        g = sample_graphs[static]['directed']
        with pytest.raises(NotImplementedError):
            alg.partition_karger(g)

    for graphs in sample_graphs.values():
        input_graph = graphs['undirected']
        output_g1, output_g2, cutset = alg.partition_karger(input_graph)
        # Check that all edges and vertices of original graph are in
        # the new graphs and the cutset.
        output_edges = output_g1.edges | output_g2.edges | cutset
        input_edges = input_graph.edges
        for edge in set(output_edges):
            output_edges.remove(edge)
            output_edges.add((tuple(sorted(edge[:2])), edge[2]))
        for edge in set(input_edges):
            input_edges.remove(edge)
            input_edges.add((tuple(sorted(edge[:2])), edge[2]))
        assert input_edges == output_edges
        assert set(output_g1.vertices + output_g2.vertices) \
            == set(input_graph.vertices)
Exemple #4
0
def test_pickling():
    """Tests serialization functionality.
    """
    for static in [True, False]:
        g = cg.graph(static=static, vertices=list(range(3)))
        g.add_edges({(0, 1), (1, 2), (2, 0)})
        with open('tmp.pickle', 'wb+') as f:
            pickle.dump(g, f)
        with open('tmp.pickle', 'rb') as f:
            loaded_g = pickle.load(f)
        os.remove('tmp.pickle')
        assert g.equals(loaded_g)
        assert loaded_g.equals(g)
Exemple #5
0
def test_get_strongly_connected_components():
    """Tests get_strongly_connected_components and
    get_number_strongly_connected_components function.
    """

    edges = [('a', 'b'), ('b', 'c'), ('b', 'e'), ('b', 'f'), ('c', 'd'),
             ('c', 'g'), ('d', 'c'), ('d', 'h'), ('h', 'd'), ('h', 'g'),
             ('g', 'f'), ('f', 'g'), ('e', 'a'), ('e', 'f')]
    component_vertices = [{'a', 'b', 'e'}, {'c', 'd', 'h'}, {'f', 'g'}]
    component_edges = [{('a', 'b'), ('b', 'e'), ('e', 'a')},
                       {('f', 'g'), ('g', 'f')},
                       {('h', 'd'), ('d', 'h'), ('d', 'c'), ('c', 'd')}]

    for static in [True, False]:
        g = cg.graph(static=static,
                     directed=True,
                     vertices=list(string.ascii_lowercase[:8]))
        for edge in edges:
            g.add_edge(*edge)
        test_components = alg.get_strongly_connected_components(g, static=True)
        for component in test_components:
            assert set(component.vertices) in component_vertices
            test_component_edges = {e[:-1] for e in component.edges}
            assert test_component_edges in component_edges

        test_components_dynamic = alg.get_strongly_connected_components(
            g, static=False)
        for component in test_components:
            assert set(component.vertices) in component_vertices
            test_component_edges = {e[:-1] for e in component.edges}
            assert test_component_edges in component_edges

        assert alg.get_number_strongly_connected_components(g) == 3

        g2 = cg.graph(static=static, directed=False)
        with pytest.raises(NotImplementedError):
            alg.get_strongly_connected_components(g2)
        with pytest.raises(NotImplementedError):
            alg.get_number_strongly_connected_components(g2)
Exemple #6
0
def test_get_connected_components():
    """Tests get_connected_components and get_number_connected_components functions.
    """

    for static in [True, False]:
        g1 = cg.graph(static=static, directed=False, vertices=['a', 'b', 'c'])
        components = alg.get_connected_components(g1, static=True)
        for component in components:
            assert component.vertices in [['a'], ['b'], ['c']]
            assert len(alg.get_connected_components(component)) == 1

        dynamic_components = alg.get_connected_components(g1, static=False)
        for component in dynamic_components:
            assert component.vertices in [['a'], ['b'], ['c']]
            assert len(alg.get_connected_components(component)) == 1

        assert alg.get_number_connected_components(g1) == 3

        g2 = cg.graph(static=static, directed=True, vertices=['a', 'b', 'c'])
        with pytest.raises(NotImplementedError):
            alg.get_connected_components(g2)
        with pytest.raises(NotImplementedError):
            alg.get_number_connected_components(g2)
Exemple #7
0
def test_vertices():
    """Tests various vertex-related methods.

    Tests methods:
        - add_vertex
        - has_vertex
        - vertices
        - remove_vertex
        - add_vertices

    for StaticGraph and DynamicGraph classes.
    """
    for static in [True, False]:
        g = cg.graph(static=static, directed=True)

        # Adding to graph with no vertices.
        g.add_vertex('s')
        # Adding to graph with vertices.
        g.add_vertex(1)
        with pytest.raises(TypeError):
            g.add_vertex([])
        with pytest.raises(ValueError):
            g.add_vertex('s')

        # vertices attribute
        assert g.vertices == ['s', 1]

        # has_vertex
        assert g.has_vertex('s')
        assert g.has_vertex(1)
        assert not g.has_vertex(2)

        # remove_vertex
        g.remove_vertex('s')
        with pytest.raises(ValueError):
            g.remove_vertex(2)
        assert not g.has_vertex('s')

        # add_vertices
        g.add_vertices({'a', 'b', 's'})
        assert g.has_vertex('a')
        assert g.has_vertex('b')
        assert g.has_vertex('s')
        with pytest.raises(ValueError):
            g.add_vertices({'c', 's'})
        assert not g.has_vertex('c')
        assert g.has_vertex('s')
Exemple #8
0
def test_edges():
    """Tests various edge-related methods.

    Tests:
        - add_edge
        - get_children
        - get_parents
        - edges
        - has_edge
        - remove_edge
        - adjacency_matrix
        - adjacency_list
        - add_edges

    for StaticGraph and DynamicGraph classes.
    """

    for static in [True, False]:
        # Directed graph.
        g = cg.graph(static=static,
                     directed=True,
                     vertices=['s', 'a', 'b', 'e'])

        # add_edge method
        g.add_edge('s', 'a',
                   weight=0.0)  # Make sure weight zero edges are tested.
        g.add_edge('a', 's')
        g.add_edge('a', 'b')
        g.add_edge('b', 'e', weight=0.5)
        with pytest.raises(ValueError):
            g.add_edge('b', 'e', weight=1.0)
        with pytest.raises(ValueError):
            g.add_edge('d', 'f')

        # set_edge_weight
        g.set_edge_weight('b', 'e', weight=1.0)
        with pytest.raises(ValueError):
            g.set_edge_weight('e', 'b', weight=1.0)

        # edges property
        g_edges = g.edges
        assert g_edges == {('s', 'a', 0.0), ('a', 'b', 1.0), ('b', 'e', 1.0),
                           ('a', 's', 1.0)}

        # has_edge
        for edge in g_edges:
            assert g.has_edge(edge[0], edge[1])
        assert not g.has_edge('e', 'b')
        assert not g.has_edge(1, 2)

        # remove_edge
        g.remove_edge('s', 'a')
        with pytest.raises(ValueError):
            g.remove_edge('sdaf', 'dsafsd')
        with pytest.warns(Warning):
            g.remove_edge('s', 'e')
        assert not g.has_edge('s', 'a')
        assert g.has_edge('a', 's')

        # get_edge_weight
        assert g.get_edge_weight('a', 'b') == 1.0
        with pytest.raises(ValueError):
            g.get_edge_weight('b', 'a')

        # get_children
        assert g.get_children('a') == {'s', 'b'}
        with pytest.raises(ValueError):
            g.get_children('d')

        # get_parents
        assert g.get_parents('e') == {'b'}
        with pytest.raises(ValueError):
            g.get_parents('d')

        # add_edges
        g.add_edges({('b', 'a', 2.0), ('e', 'b')})
        assert g.get_edge_weight('b', 'a') == 2.0
        assert g.get_edge_weight('e', 'b') == 1.0
        with pytest.raises(ValueError):
            g.add_edges({('s', 'a'), ('sdaf', 'dsafsd')})
        assert not g.has_edge('s', 'a')

        # Undirected graph.
        g2 = cg.graph(static=static,
                      directed=False,
                      vertices=['s', 'a', 'b', 'e'])

        # add_edge method
        g2.add_edge('s', 'a',
                    weight=0.0)  # Make sure weight zero edges are tested.
        g2.add_edge('a', 'b')
        g2.add_edge('b', 'e', weight=0.5)
        with pytest.raises(ValueError):
            g2.add_edge('b', 'e', weight=1.0)
        with pytest.raises(ValueError):
            g2.add_edge('d', 'f')

        # set_edge_weight
        g2.set_edge_weight('e', 'b', weight=1.0)
        with pytest.raises(ValueError):
            g2.set_edge_weight('a', 'e', weight=1.0)

        # edges property
        g2_edges = g2.edges
        assert len(g2_edges) == 3
        for edge in g2_edges:
            assert set(edge) in [{'s', 'a', 0.0}, {'a', 'b', 1.0},
                                 {'b', 'e', 1.0}]

        # has_edge
        for edge in g2_edges:
            assert g2.has_edge(edge[0], edge[1])
        assert g2.has_edge('e', 'b')
        assert not g2.has_edge(1, 2)

        # remove_edge
        g2.remove_edge('s', 'a')
        with pytest.raises(ValueError):
            g2.remove_edge('sdaf', 'dsafsd')
        with pytest.warns(Warning):
            g2.remove_edge('s', 'e')
        assert not g2.has_edge('s', 'a')
        assert not g2.has_edge('a', 's')

        # get_edge_weight
        assert g2.get_edge_weight('b', 'a') == 1.0
        with pytest.raises(ValueError):
            g2.get_edge_weight('d', 'e')

        # get_children
        assert g2.get_children('a') == {'b'}
        with pytest.raises(ValueError):
            g2.get_children('d')

        # get_parents
        assert g2.get_parents('a') == {'b'}
        with pytest.raises(ValueError):
            g2.get_parents('d')

        # add_edges
        g.remove_edge('e', 'b')
        g.add_edges({('s', 'e', 2.0), ('e', 'b')})
        assert g.get_edge_weight('s', 'e') == 2.0
        assert g.get_edge_weight('e', 'b') == 1.0
        with pytest.raises(ValueError):
            g.add_edges({('s', 'a'), ('sdaf', 'dsafsd')})
        assert not g.has_edge('s', 'a')

        # adjacency_matrix and adjacency_list
        g = cg.graph(static=static, directed=False, vertices=list(range(3)))
        g.add_edge(0, 1)
        g.add_edge(1, 2)
        undirected_adj = [[0, 1, 0], [1, 0, 1], [0, 1, 0]]
        if static:
            assert (np.nan_to_num(g.adjacency_matrix) == undirected_adj).all()
        else:
            assert g.adjacency_matrix == \
                [[None if not x else x for x in lst] for lst in undirected_adj]
        assert g.adjacency_list == [[1], [0, 2], [1]]
        g = cg.graph(static=static, directed=True, vertices=list(range(3)))
        g.add_edge(0, 1)
        g.add_edge(1, 2)
        directed_adj = [[0, 1, 0], [0, 0, 1], [0, 0, 0]]
        if static:
            assert (np.nan_to_num(g.adjacency_matrix) == directed_adj).all()
        else:
            assert g.adjacency_matrix == \
                [[None if not x else x for x in lst] for lst in directed_adj]
        assert g.adjacency_list == [[1], [2], []]
Exemple #9
0
def test_attributes():
    """Tests various edge and vertex attribute-related methods.

    Tests:
        - set_vertex_attribute
        - get_vertex_attribute
        - set_edge_attribute
        - get_edge_attribute

    for StaticGraph and DynamicGraph classes
    """

    # Edge attributes.
    for static in [True, False]:
        # Directed graph.
        g = cg.graph(static=static, directed=True, vertices=['a', 'b', 'c'])
        g.add_edge('a', 'b')

        # Setting attributes.
        g.set_edge_attribute(('a', 'b'), key='key', val='val')
        with pytest.raises(TypeError):
            g.set_edge_attribute(('a', 'b'), key=[], val='val')
        with pytest.raises(ValueError):
            g.set_edge_attribute(('b', 'a'), key='key 2', val='val')
        g.set_edge_attribute(('a', 'b'), key='key', val='new val')

        # set_edge_attributes
        g.set_edge_attributes(('a', 'b'), {'key1': 'val1', 'key2': 'val2'})
        with pytest.raises(ValueError):
            g.set_edge_attributes(('b', 'a'), {'key1': 'val1', 'key2': 'val2'})

        # Getting attributes.
        assert g.get_edge_attribute(('a', 'b'), key='key') == 'new val'
        assert g.get_edge_attribute(('a', 'b'), key='key1') == 'val1'
        assert g.get_edge_attribute(('a', 'b'), key='key2') == 'val2'
        with pytest.raises(TypeError):
            g.get_edge_attribute(('a', 'b'), key=[])
        with pytest.raises(ValueError):
            g.get_edge_attribute(('b', 'a'), key='key')
        with pytest.raises(KeyError):
            g.get_edge_attribute(('a', 'b'), key="this is not a key")

        # Removing attributes.
        with pytest.raises(ValueError):
            g.remove_edge_attribute(('a', 'c'), key='key')
        with pytest.raises(ValueError):
            g.remove_edge_attribute(('b', 'a'), key='key')
        with pytest.raises(KeyError):
            g.remove_edge_attribute(('a', 'b'), key="this is not a key")
        g.remove_edge_attribute(('a', 'b'), key='key')
        with pytest.raises(KeyError):
            g.get_edge_attribute(('a', 'b'), key='key')

        # Undirected graph.
        g2 = cg.graph(static=static, directed=False, vertices=['a', 'b', 'c'])
        g2.add_edge('a', 'b')

        # Setting attributes.
        g2.set_edge_attribute(('a', 'b'), key='key', val='val')
        with pytest.raises(TypeError):
            g2.set_edge_attribute(('a', 'b'), key=[], val='val')
        with pytest.raises(ValueError):
            g2.set_edge_attribute(('a', 'c'), key='key 2', val='val')
        g2.set_edge_attribute(('a', 'b'), key='key', val='new val')

        # set_edge_attributes
        g2.set_edge_attributes(('a', 'b'), {'key1': 'val1', 'key2': 'val2'})

        # Getting attributes.
        assert g2.get_edge_attribute(('a', 'b'), key='key') == 'new val'
        assert g2.get_edge_attribute(('b', 'a'), key='key') == 'new val'
        assert g2.get_edge_attribute(('a', 'b'), key='key1') == 'val1'
        assert g2.get_edge_attribute(('a', 'b'), key='key2') == 'val2'
        with pytest.raises(TypeError):
            g2.get_edge_attribute(('a', 'b'), key=[])
        with pytest.raises(ValueError):
            g2.get_edge_attribute(('a', 'c'), key='key')
        with pytest.raises(KeyError):
            g2.get_edge_attribute(('a', 'b'), key="this is not a key")

        # Removing attributes.
        with pytest.raises(ValueError):
            g2.remove_edge_attribute(('a', 'c'), key='key')
        with pytest.raises(KeyError):
            g2.remove_edge_attribute(('a', 'b'), key="this is not a key")
        g2.remove_edge_attribute(('a', 'b'), key='key')
        with pytest.raises(KeyError):
            g2.get_edge_attribute(('a', 'b'), key='key')
        with pytest.raises(KeyError):
            g2.get_edge_attribute(('b', 'a'), key='key')
        g2.set_edge_attribute(('a', 'b'), key='key', val='val')
        g2.remove_edge_attribute(('b', 'a'), key='key')
        with pytest.raises(KeyError):
            g2.get_edge_attribute(('a', 'b'), key='key')
        with pytest.raises(KeyError):
            g2.get_edge_attribute(('b', 'a'), key='key')

    # Vertex attributes.
    for static in [True, False]:
        for directed in [True, False]:
            g = cg.graph(static=static,
                         directed=directed,
                         vertices=['a', 'b', 'c'])

            # Setting attributes
            g.set_vertex_attribute('a', key='key', val='val')
            with pytest.raises(TypeError):
                g.set_vertex_attribute('a', key=[], val='val')
            with pytest.raises(ValueError):
                g.set_vertex_attribute('d', key='key', val='val')

            # Getting attributes
            assert g.get_vertex_attribute('a', key='key') == 'val'
            with pytest.raises(TypeError):
                g.get_vertex_attribute('a', key=[])
            with pytest.raises(ValueError):
                g.get_vertex_attribute('d', key='key')
            with pytest.raises(KeyError):
                g.get_vertex_attribute('a', key='this is not a key')

            # Removing attributes
            with pytest.raises(TypeError):
                g.remove_vertex_attribute('a', key=[])
            with pytest.raises(ValueError):
                g.remove_vertex_attribute('d', key='key')
            with pytest.raises(KeyError):
                g.remove_vertex_attribute('a', key="this is not a key")
            g.remove_vertex_attribute('a', 'key')
            with pytest.raises(KeyError):
                g.get_vertex_attribute('a', key='key')
Exemple #10
0
def test_constructor():
    """Tests initialization of a StaticGraph and DynamicGraph objects.
    """

    graphs = []

    # Smoke tests.
    cg.graph()
    vertex_lists = [['s', 'e'], [0, 1]]
    for lst in vertex_lists:
        for directed in [True, False]:
            for static in [True, False]:
                g = cg.graph(static=static, directed=directed, vertices=lst)
                graphs.append(g)

    # Exception-raising tests.
    for directed in [True, False]:
        for static in [True, False]:
            with pytest.raises(TypeError):
                # Non-hashable type vertices.
                g = cg.graph(static=static,
                             directed=directed,
                             vertices=[['s'], ['e']])
                graphs.append(g)

    # Generating from graph data structures.
    adjacency_matrix = [[0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0],
                        [0, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 0],
                        [0, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1],
                        [0, 0, 0, 0, 0, 1, 0]]
    adjacency_list = [[1], [0, 2], [1, 3, 4, 5], [2], [2, 5], [2, 4, 6], [5]]
    edges = [(0, 1), (1, 2), (2, 3), (2, 4), (2, 5), (4, 5), (5, 6)]
    for static in [True, False]:
        adj_list_graph = cg.graph(static=static,
                                  vertices=list(range(7)),
                                  adjacency_list=adjacency_list)
        if static:
            np_adjacency_matrix = [[val if val else np.nan for val in row]
                                   for row in adjacency_matrix]
            np_adjacency_matrix = np.array(np_adjacency_matrix)
            adj_mat_graph = cg.graph(static=static,
                                     vertices=list(range(7)),
                                     adjacency_matrix=np_adjacency_matrix)
        else:
            adj_mat_graph = cg.graph(
                static=static,
                vertices=list(range(7)),
                adjacency_matrix=[[val if val else None for val in row]
                                  for row in adjacency_matrix])
        for edge in edges:
            assert adj_list_graph.has_edge(*edge)
            assert adj_mat_graph.has_edge(*edge)
        for edge in adj_mat_graph.edges:
            assert edge[:-1] in edges
        for edge in adj_list_graph.edges:
            assert edge[:-1] in edges
        graphs.append(adj_list_graph)
        graphs.append(adj_mat_graph)

    # Copying another graph.
    for graph in graphs:
        g = cg.graph(graph_=graph)
        assert g.vertices == graph.vertices
        assert g.edges == graph.edges
Exemple #11
0
 def __init__(self):
     self.graph = cg.graph(static=False,
                           graph_=None,
                           directed=True,
                           vertices=[])
Exemple #12
0
def test_get_articulation_points():
    """Tests get_articulation_points function.
    """
    random_graph = {
        0: {74, 11, 76},
        1: {33, 59, 77},
        2: {53, 78},
        3: {64},
        4: {74},
        5: {80, 81, 89},
        6: {29, 70, 47},
        7: {8},
        8: {58, 36, 7, 95},
        9: {26, 23},
        10: set(),
        11: {0, 70},
        12: {73},
        13: {99, 62, 39},
        14: set(),
        15: {26, 50, 76},
        16: {93, 22},
        17: {84, 86},
        18: {50, 77},
        19: set(),
        20: {56, 58, 66, 39},
        21: {97, 67, 71, 50, 28},
        22: {16, 77},
        23: {9},
        24: {49, 33},
        25: set(),
        26: {9, 15},
        27: {41, 82, 33},
        28: {80, 21, 70},
        29: {43, 6},
        30: {73, 46},
        31: {80, 50, 82},
        32: {46},
        33: {1, 73, 80, 24, 57, 27},
        34: {48, 84, 70, 71},
        35: {65, 63},
        36: {8, 46, 47},
        37: set(),
        38: {98, 85},
        39: {69, 20, 13, 54},
        40: {66},
        41: {56, 27},
        42: set(),
        43: {88, 29},
        44: {68},
        45: {48},
        46: {32, 36, 30},
        47: {36, 6},
        48: {81, 34, 45},
        49: {24, 81, 54},
        50: {18, 15, 21, 31},
        51: set(),
        52: set(),
        53: {2},
        54: {65, 49, 39},
        55: {89},
        56: {65, 41, 73, 20, 59},
        57: {33},
        58: {8, 97, 20},
        59: {56, 1},
        60: set(),
        61: set(),
        62: {13},
        63: {35},
        64: {3},
        65: {56, 81, 35, 54},
        66: {40, 90, 20},
        67: {21},
        68: {44},
        69: {97, 93, 39},
        70: {34, 6, 11, 86, 28},
        71: {73, 34, 21},
        72: {98, 94},
        73: {33, 71, 12, 56, 30},
        74: {0, 4},
        75: set(),
        76: {0, 15},
        77: {1, 18, 22},
        78: {2},
        79: set(),
        80: {33, 5, 87, 28, 31},
        81: {65, 49, 48, 5},
        82: {27, 31},
        83: {87},
        84: {17, 34},
        85: {90, 38},
        86: {17, 70},
        87: {80, 83},
        88: {43},
        89: {5, 55},
        90: {66, 85},
        91: set(),
        92: set(),
        93: {16, 69},
        94: {72},
        95: {8},
        96: set(),
        97: {58, 69, 21},
        98: {72, 38},
        99: {13}
    }
    sample_graphs = {
        'static': {
            'undirected':
            cg.graph(static=True, directed=False, vertices=list(random_graph)),
            'directed':
            cg.graph(static=True, directed=True, vertices=list(random_graph))
        },
        'dynamic': {
            'undirected':
            cg.graph(static=False, directed=False,
                     vertices=list(random_graph)),
            'directed':
            cg.graph(static=False, directed=True, vertices=list(random_graph))
        }
    }
    for graph in [g for s in sample_graphs for g in sample_graphs[s].values()]:
        for vertex in random_graph:
            for neighbor in random_graph[vertex]:
                if not graph.has_edge(vertex, neighbor):
                    graph.add_edge(vertex, neighbor)

    random_graph_articulation_points = {
        33, 46, 48, 13, 39, 21, 89, 5, 87, 80, 35, 65, 73, 9, 26, 15, 72, 98,
        38, 85, 90, 66, 20, 8, 43, 29, 6, 74, 0, 2
    }

    for static in sample_graphs:
        g1 = sample_graphs[static]['directed']
        with pytest.raises(NotImplementedError):
            alg.get_articulation_points(g1)

        g2 = sample_graphs[static]['undirected']
        assert alg.get_articulation_points(
            g2) == random_graph_articulation_points