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)
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)
def incident_edges_outgoing(self) -> SetView[MultiDiEdge]: return SetView(self._incident_edges.outgoing)
def incident_edges_incoming(self) -> SetView[MultiDiEdge]: return SetView(self._incident_edges.incoming)
def adj_vertices_outgoing(self) -> SetView[MultiDiVertex]: return SetView(self._incident_edges.adj_vertices_outgoing)
def incident_edges(self) -> SetView[MultiEdge]: return SetView(self._incident_edges.incident_edges)
def adj_vertices(self) -> SetView[MultiVertex]: return SetView(self._incident_edges.adj_vertices)
def adj_vertices_incoming(self) -> SetView[DiVertex]: return SetView(self._incident_edges.adj_vertices_incoming)
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)
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)
def incident_edges_outgoing(self) -> SetView[PseudoEdge]: return SetView(self._incident_edges.outgoing)
def incident_edges_incoming(self) -> SetView[PseudoEdge]: return SetView(self._incident_edges.incoming)