In a simple graph each edge connects two different vertices and no two edges connect the same pair of vertices.
A multigraph may have multiple edges connecting the same two vertices. When \(m\) different edges connect the vertices \(u\) and \(v\), we say that \(\{u, v\}\) is an edge with multiplicity \(m\).
An edge that connects a vertex to itself is called a loop.
A pseudograph may include loops, as well as multiple edges connecting the same pair of vertices.
A simple directed graph has no loops and no multiple edges
A directed multigraph may have multiple directed edges. When there are \(m\) directed edges from the vertex \(u\) to the vertex \(v\), we say that \((u,v)\) is an edge of multiplicity \(m\).
Type | Edges | Multiple Edges | Loops |
---|---|---|---|
Simple graph | Undirected | No | No |
Multigraph | Undirected | Yes | No |
Pseudograph | Undirected | Yes | Yes |
Simple directed graph | Directed | No | No |
Directed multigraph | Directed | Yes | Yes |
Mixed graph | Both | Yes | Yes |
Adjacency matrices can also be used to represent graphs with loops and multiple edges.
A loop at the vertex \(v_i\) is represented by a 1 at the \((i,j)th\) position of the matrix.
When multiple edges connect the same pair of vertices \(v_i\) and \(v_j\), the \((i,j)th\) entry equals the number of edges connecting the pair of vertices.
Adjacency matrices can also be used to represent directed graphs. The matrix for a directed graph \(G = (V,E)\) has a 1 in its \((i,j)th\) position if there is an edge from \(v_i\) to \(v_j\) where \(v_1, v_2, \hdots, v_n\) is a list of vertices.
The adjacency matrix for a directed graph does not have to be symmetric because there may not be an edge from \(v_i\) to \(v_j\) when there is an edge from \(v_j\) to \(v_i\).
To represent directed multigraphs, the value of \(a_{ij}\) is the number of edges connecting \(v_i\) to \(v_j\).
Definition: Let \(n\) be a nonnegative integer and \(G\) an undirected graph. A path of length \(n\) from \(u\) to \(v\) in \(G\) is a sequence of \(n\) edges \(e_1, \ldots, e_n\) of \(G\) for which there exists a sequence \(x_0 = u, x_1, \ldots, x_{n-1}, x_n = v\) of vertices such that \(e_i\) has, for \(i = 1, \ldots, n\), the endpoints \(x_{i-1}\) and \(x_i\).
When the graph is simple, we denote this path by its vertex sequence \(x_0, x_1, \ldots, x_n\) (since listing the vertices uniquely determines the path).
The path is a circuit if it begins and ends at the same vertex (\(u = v\)) and has length greater than zero.
The path or circuit is said to pass through the vertices \(x_1, x_2, \ldots, x_{n-1}\) and traverses the edges \(e_1, \ldots, e_n\).
A path or circuit is simple if it does not contain the same edge more than once.
Definition: An undirected graph is called connected if there is a path between every pair of vertices. An undirected graph is that is not connected is called disconnected. We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph.
Definition: A connected component of a graph \(G\) is a connected subgraph of \(G\) that is not a proper subgraph of another connected subgraph of \(G\).
Definition: An directed graph is called strongly connected if there is a path from \(a\) to \(b\) and a path from \(b\) to \(a\) whenever \(a\) and \(b\) are vertices in the graph.
Definition: A directed graph is weakly connected if there is a path between every two vertices in the underlying undirected graph, which is the undirected graph obtained by ignoring the directions of the edges of the directed graph.
Definition: A tree is a connected undirected graph with no simple circuits.
Definition: A forest is a graph that has no simple circuit but is not connected. Each of the connected components in a forest is a tree.
A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root.
An unrooted tree is converted into different rooted trees when different vertices are chosen as the root.
If \(v\) is a vertex of a rooted tree other than the root, the parent of \(v\) is the unique vertex \(u\) such that there is a directed edge from \(u\) to \(v\). When \(u\) is a parent of \(v\), \(v\) is called the child of \(u\). Vertices with the same parent are called siblings.
The ancestors of a vertex are the vertices in the path from the root to this vertex, excluding the vertex itself and including the root.
The descendants of a vertex \(v\) are those vertices that have \(v\) as an ancestor.
A vertex of a rooted tree with no children is called a leaf. Vertices that have children are called internal vertices.
If \(a\) is a vertex in a tree, the subtree with \(a\) as its root is a tree consisting of \(a\) and its descendants and all edges incident to these descendants.
Definition: A weighted graph is a graph in which the edges have been assigned weights where the weights are numerical values.
The shortest path problem is the problem of finding a path between two vertices in a weighted graph such that the sum of the weights of its constituent edges is minimized.
Dijkstra’s algorithm solves the problem of finding the shortest path from a source vertex \(v \in V\) to all other vertices in the graph assuming that the weights are nonnegative.