Exemplo n.º 1
0
    def edges(self) -> "SetView[E_co]":
        """Returns a :class:`SetView <vertizee.classes.collection_views.SetView>` of the component
        edges."""
        if self._edge_set:
            return SetView(self._edge_set)

        self._edge_set = set()
        vertices = self._vertices.values()
        for vertex in vertices:
            for edge in vertex.incident_edges():
                if edge.vertex1 in vertices and edge.vertex2 in vertices:
                    if edge not in self._edge_set:
                        self._edge_set.add(cast(E_co, edge))
        return SetView(self._edge_set)
Exemplo n.º 2
0
    def test_set_view(self) -> None:
        set1 = {10, 11, 12}
        set_view = SetView(set1)

        assert len(set_view) == 3
        assert 10 in set_view
        assert 13 not in set_view
        assert set_view & {9, 10, 11} == {10, 11}
        assert set_view | {12, 13, 14} == {10, 11, 12, 13, 14}
        assert repr(set_view) == "SetView({10, 11, 12})"
        assert str(set_view) == repr(set_view)

        set_view2 = SetView._from_iterable(["a", "b", "c", "d", "d"])
        assert len(set_view2) == 4
        assert "d" in set_view2
        assert isinstance(set_view2, SetView)
Exemplo n.º 3
0
 def incident_edges_outgoing(self) -> SetView[MultiDiEdge]:
     return SetView(self._incident_edges.outgoing)
Exemplo n.º 4
0
 def incident_edges_incoming(self) -> SetView[MultiDiEdge]:
     return SetView(self._incident_edges.incoming)
Exemplo n.º 5
0
 def adj_vertices_outgoing(self) -> SetView[MultiDiVertex]:
     return SetView(self._incident_edges.adj_vertices_outgoing)
Exemplo n.º 6
0
 def incident_edges(self) -> SetView[MultiEdge]:
     return SetView(self._incident_edges.incident_edges)
Exemplo n.º 7
0
 def adj_vertices(self) -> SetView[MultiVertex]:
     return SetView(self._incident_edges.adj_vertices)
Exemplo n.º 8
0
 def adj_vertices_incoming(self) -> SetView[DiVertex]:
     return SetView(self._incident_edges.adj_vertices_incoming)
Exemplo n.º 9
0
 def tree_edges(self) -> "SetView[E_co]":
     """Returns a :class:`SetView <vertizee.classes.collection_views.SetView>` of the tree
     edges found during the graph search."""
     return SetView(self._tree_edges)
Exemplo n.º 10
0
 def forward_edges(self) -> "SetView[E_co]":
     """Returns a :class:`SetView <vertizee.classes.collection_views.SetView>` of the forward
     edges found during a graph search."""
     return SetView(self._forward_edges)
Exemplo n.º 11
0
 def incident_edges_outgoing(self) -> SetView[PseudoEdge]:
     return SetView(self._incident_edges.outgoing)
Exemplo n.º 12
0
 def incident_edges_incoming(self) -> SetView[PseudoEdge]:
     return SetView(self._incident_edges.incoming)