Source code for geographer.graph.bipartite_graph_class
"""ABC for bipartite graphs."""from__future__importannotationsfromabcimportABCfrompathlibimportPathfromtypingimportAnyfromgeographer.graph.type_aliasesimportVertexColor,VertexName
[docs]classBipartiteGraphClass(ABC):"""ABC for bipartite graphs. The decomposition of a vertex set into two sets are thought of as vertex colors, e.g. red or black. The graph can be directed or not and the edges can have extra data. e.g. a name, a color, a weight, possibly even composite data in the form of tuples. """
[docs]defvertices(self,color:VertexColor)->list[VertexName]:"""Return vertices of a given color."""raiseNotImplementedError
[docs]defvertices_opposite(self,vertex_name:VertexName,vertex_color:VertexColor,edge_data:Any|None=None,)->list[VertexColor]:"""Return list of adjacent vertices."""raiseNotImplementedError
[docs]defexists_vertex(self,vertex_name:VertexName,vertex_color:VertexColor,)->bool:"""Return True if the vertex is in the graph, False otherwise."""raiseNotImplementedError
[docs]defexists_edge(self,from_vertex:VertexName,from_vertex_color:VertexColor,to_vertex:VertexName,edge_data:Any|None,)->bool:"""Return True if the edge is in the graph, False otherwise."""raiseNotImplementedError
[docs]defadd_vertex(self,vertex_name:VertexName,vertex_color:VertexColor):"""Add a vertex to the graph."""raiseNotImplementedError
[docs]defadd_edge(self,from_vertex:VertexName,from_vertex_color:VertexColor,to_vertex:VertexName,edge_data:Any,force:bool=False,):"""Add edge to graph."""raiseNotImplementedError
[docs]defdelete_vertex(self,vertex_name:VertexName,vertex_color:VertexColor,force_delete_with_edges=True,):"""Delete vertex from graph."""raiseNotImplementedError
[docs]defdelete_edge(self,from_vertex:VertexName,from_vertex_color:VertexColor,to_vertex:VertexName,):"""Delete edge from graph."""raiseNotImplementedError
[docs]defsave_to_file(self,file_path:Path|None=None):"""Save graph to file."""raiseNotImplementedError
[docs]defreally_undirected(self)->bool:"""Return True if graph is really undirected."""raiseNotImplementedError