Graph connectivity #
In a simple graph,
-
A walk is a finite sequence of adjacent vertices, and can be thought of equally well as a sequence of directed edges.
-
A trail is a walk whose edges each appear no more than once.
-
A path is a trail whose vertices appear no more than once.
-
A cycle is a nonempty trail whose first and last vertices are the same and whose vertices except for the first appear no more than once.
Warning: graph theorists mean something different by "path" than do homotopy theorists. A "walk" in graph theory is a "path" in homotopy theory. Another warning: some graph theorists use "path" and "simple path" for "walk" and "path."
Some definitions and theorems have inspiration from multigraph counterparts in [Cho94].
Main definitions #
-
simple_graph.is_trail,simple_graph.is_path, andsimple_graph.is_cycle. -
simple_graph.path
Tags #
walks, trails, paths, circuits, cycles
- nil : Π {V : Type u} {G : simple_graph V} {u : V}, G.walk u u
- cons : Π {V : Type u} {G : simple_graph V} {u v w : V}, G.adj u v → G.walk v w → G.walk u w
A walk is a sequence of adjacent vertices. For vertices u v : V,
the type walk u v consists of all walks starting at u and ending at v.
We say that a walk visits the vertices it contains. The set of vertices a
walk visits is simple_graph.walk.support.
Equations
The length of a walk is the number of edges along it.
Equations
- (simple_graph.walk.cons _x_2 q).length = q.length.succ
- simple_graph.walk.nil.length = 0
The concatenation of two compatible walks.
Equations
- (simple_graph.walk.cons h p).append q = simple_graph.walk.cons h (p.append q)
- simple_graph.walk.nil.append q = q
The concatenation of the reverse of the first walk with the second walk.
Equations
- (simple_graph.walk.cons h p).reverse_aux q = p.reverse_aux (simple_graph.walk.cons _ q)
- simple_graph.walk.nil.reverse_aux q = q
The walk in reverse.
Equations
Get the nth vertex from a walk, where n is generally expected to be
between 0 and p.length, inclusive.
If n is greater than or equal to p.length, the result is the path's endpoint.
Equations
- (simple_graph.walk.cons _x q).get_vert (n + 1) = q.get_vert n
- (simple_graph.walk.cons _x _x_1).get_vert 0 = u
- simple_graph.walk.nil.get_vert _x = u
The support of a walk is the list of vertices it visits in order.
Equations
- (simple_graph.walk.cons h p).support = u :: p.support
- simple_graph.walk.nil.support = [u]
The edges of a walk is the list of edges it visits in order.
Every edge in a walk's edge list is an edge of the graph. It is written in this form to avoid unsightly coercions.
A trail is a walk with no repeating edges.
A path is a walk with no repeating vertices.
Use simple_graph.walk.is_path.mk' for a simpler constructor.
- to_trail : p.is_trail
- ne_nil : p ≠ simple_graph.walk.nil
A circuit at u : V is a nonempty trail beginning and ending at u.
- to_circuit : p.is_circuit
- support_nodup : p.support.tail.nodup
A cycle at u : V is a circuit at u whose only repeating vertex
is u (which appears exactly twice).