What is difference between cycle, path and circuit in Graph Theory
All of these are sequences of vertices and edges. They have the following properties :
- Walk : Vertices may repeat. Edges may repeat (Closed or Open)
- Trail : Vertices may repeat. Edges cannot repeat (Open)
- Circuit : Vertices may repeat. Edges cannot repeat (Closed)
- Path : Vertices cannot repeat. Edges cannot repeat (Open)
- Cycle : Vertices cannot repeat. Edges cannot repeat (Closed)
NOTE : For closed sequences start and end vertices are the only ones that can repeat.
Usually a path in general is same as a walk which is just a sequence of vertices such that adjacent vertices are connected by edges. Think of it as just traveling around a graph along the edges with no restrictions.
Some books, however, refer to a path as a "simple" path. In that case when we say a path we mean that no vertices are repeated. We do not travel to the same vertex twice (or more).
A cycle is a closed path. That is, we start and end at the same vertex. In the middle, we do not travel to any vertex twice.
It will be convenient to define trails before moving on to circuits. Trails refer to a walk where no edge is repeated. (Observe the difference between a trail and a simple path)
Circuits refer to the closed trails, meaning we start and end at the same vertex.
Different books have different terminology in some books a simple path means in which none of the edges are repeated and a circuit is a path which begins and ends at same vertex,and circuit and cycle are same thing in these books.
Books which use the term walk have different definitions of path and circuit,here, walk is defined to be an alternating sequence of vertices and edges of a graph, a trail is used to denote a walk that has no repeated edge here a path is a trail with no repeated vertices, closed walk is walk that starts and ends with same vertex and a circuit is a closed trail.