8.1: Directed Graphs
- Page ID
- 49315
The number of edges with one endpoint on a given vertex is called that vertex's degree. In a directed graph, the number of edges that point to a given vertex is called its in-degree, and the number that point from it is called its out-degree. Often, we may want to be able to distinguish between different nodes and edges. We can associate labels with either. We call such a graph labeled.
Directed Graph Operations
make-graph(): graph
Create a new graph, initially with no nodes or edges.
make-vertex(graph G, element value): vertex
Create a new vertex, with the given value.
make-edge(vertex u, vertex v): edge
Create an edge between u and v. In a directed graph, the edge will flow from u to v.
get-edges(vertex v): edge-set
Returns the set of edges flowing from v
get-neighbors(vertex v): vertex-set
Returns the set of vertices connected to v