class documentation

class Graph:

View In Hierarchy

Representation of a simple graph using an adjacency map.

Class Edge Lightweight edge structure for a graph.
Class Vertex Lightweight vertex structure for a graph.
Method __init__ Create an empty graph (undirected, by default).
Method degree Return number of (outgoing) edges incident to vertex v in the graph.
Method edge_count Return the number of edges in the graph.
Method edges Return a set of all edges of the graph.
Method get_edge Return the edge from u to v, or None if not adjacent.
Method incident_edges Return all (outgoing) edges incident to vertex v in the graph.
Method insert_edge Insert and return a new Edge from u to v with auxiliary element x.
Method insert_vertex Insert and return a new Vertex with element x.
Method is_directed Return True if this is a directed graph; False if undirected.
Method vertex_count Return the number of vertices in the graph.
Method vertices Return an iteration of all vertices of the graph.
Method _validate_vertex Verify that v is a Vertex of this graph.
Instance Variable _incoming Undocumented
Instance Variable _outgoing Undocumented
def __init__(self, directed=False):

Create an empty graph (undirected, by default).

Graph is directed if optional paramter is set to True.

def degree(self, v, outgoing=True):

Return number of (outgoing) edges incident to vertex v in the graph.

If graph is directed, optional parameter used to count incoming edges.

def edge_count(self):

Return the number of edges in the graph.

def edges(self):

Return a set of all edges of the graph.

def get_edge(self, u, v):

Return the edge from u to v, or None if not adjacent.

def incident_edges(self, v, outgoing=True):

Return all (outgoing) edges incident to vertex v in the graph.

If graph is directed, optional parameter used to request incoming edges.

def insert_edge(self, u, v, x=None):

Insert and return a new Edge from u to v with auxiliary element x.

Raise a ValueError if u and v are not vertices of the graph. Raise a ValueError if u and v are already adjacent.

def insert_vertex(self, x=None):

Insert and return a new Vertex with element x.

def is_directed(self):

Return True if this is a directed graph; False if undirected.

Property is based on the original declaration of the graph, not its contents.

def vertex_count(self):

Return the number of vertices in the graph.

def vertices(self):

Return an iteration of all vertices of the graph.

def _validate_vertex(self, v):

Verify that v is a Vertex of this graph.

_incoming =

Undocumented

_outgoing: dict =

Undocumented