![]() |
VOOZH | about |
Walks, trails, paths, cycles, and circuits in a graph are sequences of vertices and edges with different properties. Some allow repetition of vertices and edges, while others do not.
A walk in a graph is a sequence of vertices and edges where both edges and vertices can be repeated. The length of the walk refers to the number of edges covered in the sequence. A graph can contain multiple walks.
There are two key points to note about a walk:
- Here, 1-> 2-> 3-> 4-> 2-> 1-> 3 is a walk.
Walk can be open or closed.
There are two types of walks:
Open Walk: An open walk is a walk in which the starting and ending vertices are different. In other words, for a walk to be considered open, the origin and terminal vertices must not be the same. Additionally, the length of the walk must be greater than 0.
Closed Walk: A closed walk occurs when the starting and ending vertices are identical, meaning the walk starts and ends at the same vertex. For a walk to be classified as closed, the origin and terminal vertices must be the same. Similar to an open walk, the length of the walk must be greater than 0.
In the above diagram:
- 1-> 2-> 3-> 4-> 5-> 3 is an open walk.
- 1-> 2-> 3-> 4-> 5-> 3-> 1 is a closed walk.
A trail is an open walk in which no edge is repeated, though vertices may be repeated.
There are two types of trails:
In a trail, the key point to remember is that: Edges cannot be repeated, but vertices can be repeated.
Here 1-> 3-> 8-> 6-> 3-> 2 is trail
Also 1-> 3-> 8-> 6-> 3-> 2-> 1 will be a closed trail
A circuit can be described as a closed trail in graph theory, where no edge is repeated, but vertices can be repeated.
Thus, the key characteristics of a circuit are:
In other words, a circuit is a closed traversal of a graph where each edge is used exactly once, but a vertex may appear more than once.
Here 1-> 2-> 4-> 3-> 6-> 8-> 3-> 1 is a circuit.
Circuit is a closed trail.
A path is a trail in which neither vertices nor edges are repeated.
In other words, when traversing a graph along a path, each vertex and each edge is visited exactly once. Since a path is also a trail, it is inherently an open walk unless stated otherwise.
Another definition of a path is a walk with no repeated vertices. This automatically implies that no edges are repeated, making it unnecessary to explicitly mention edge repetition in the definition.
Key characteristics of a path:
Here 6->8->3->1->2->4 is a Path
A cycle in graph is a closed path, meaning that it starts and ends at the same vertex while ensuring that no other vertices or edges are repeated.
In other words, a cycle is formed by traversing a graph such that: No vertex is repeated, except for the starting and ending vertex, which must be the same and No edge is repeated.
Key characteristics of a cycle:
Here 1->2->4->3->1 is a cycle.
Cycle is a closed path.
The table below represents the repetition of edges and vertices in walk, trail and path.
Category | Edges | Vertices |
|---|---|---|
Walk | Can be repeated | Can be repeated |
Trail | Cannot be repeated | Can be repeated |
Path | Cannot be repeated | Cannot be repeated |
Question 1. Find a trail from A to D for below graph
A - B
| |
C - D
One possible trail is: A → B → D.
Question 2. Find the shortest path from A to C.
A - B - C
| |
D - E
The shortest path is: A → B → C.
Question 3. Finding All Possible Paths
A - B - C
| |
D - E
The path is : A → B → C
Graph for Reference:
A
/ | \
B C D
\ | /
E
|
F