-
Notifications
You must be signed in to change notification settings - Fork 2
Graph Theory Reminder
Mark Junker edited this page Jun 7, 2018
·
1 revision
This is intended to refresh these notions for those who have not played with them recently. It is also intended to specify the standards names used in the project and the library itself. As much as possible, QuickGraph naming convention follows the standard of graph theory naming.

Let us start by redefining the basic concepts of directed graphs, vertices and edges. All these definitions are illustrated in the figure above.
- A directed graph
G=(VxE)consists of a finite setV=V(G)of vertices and a finite multi-setEcontained inVxV = {(u,v)| u,v in V}of edges that are ordered pair of vertices whereuis called the source vertex andvthe target vertex.
Tip:
-
TVertexandTEdgeare generic parameters in QuickGraph. TheTEdgeparameter has an additional constraint that it has to implementIEdge<TVertex>.
public interface IEdge<TVertex>
{
TVertex Source {get;}
TVertex Target { get;}
}public interface ISomeGraphAlgorithm<TVertex,TEdge>
where Edge : IEdge<TVertex>
{…}- If
e=(u,v), theneis an out-edge ofuand an in-edge ofv.in-degree(v)denotes the number of incoming edges ofvandout-degree(u), the number of outgoing edges ofu. The degree ofuis the sum of its in-degree and out-degree. - If a graph allows multiple edges from the same (
u,v) vertex pair, it is called a multi-graph. Such edges are called parallel edges. - A path from
utovis a sequence of edgese1,e2,...,ensuch thate1source isu,entarget isvand each edge in the sequence is an out-edge of it’s predecessor. - A cycle is a path where the beginning vertex is equal to the end vertex.
- A directed acyclic graph (DAG) is a directed graph with no cycle.
- A weighted directed graph
G:(VxExW)is a directed graph with an additional relation that associate each edge to a weight:e -> w(e)(for example, the distance). - An adjacency graph is a data structure to represent a directed graph where the out-edges of any vertex can be accessed in amortized constant time.
- A bidirectional graph is a data structure to represent directed graph where both the out-edges and the in-edges of any vertex can be accessed in amortized constant time.
- QuickGraph also provides data structures for UndirectedGraph.
tip: The adjacency graph is implemented as a dictionary of Vertex to a collection of out-edges. When using a bidirectional graph, two dictionaries (one for in-edges, one for out-edges) have to be used, which doubles the required memory. Such data structures are most efficient for sparse graphs.