# Mathematics | Walks, Trails, Paths, Cycles and Circuits in Graph

Prerequisite – Graph Theory Basics – Set 1

**1. Walk –**

A walk is a sequence of vertices and edges of a graph i.e. if we traverse a graph then we get a walk.

Vertex can be repeated

Edges can be repeated

Here 1->2->3->4->2->1->3 is a walk

Walk can be open or closed. Walk can repeat anything (edges or vertices).

**Open walk-**A walk is said to be an open walk if the starting and ending vertices are different i.e. the origin vertex and terminal vertex are different.

**Closed walk-**A walk is said to be a closed walk if the starting and ending vertices are identical i.e. if a walk starts and ends at the same vertex, then it is said to be a closed walk.

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.

**2. Trail –**

Trail is an open walk in which no edge is repeated.

Vertex 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

**3. Circuit –**

Traversing a graph such that not an edge is repeated but vertex can be repeated and it is closed also i.e. it is a closed trail.

Vertex can be repeated

Edge not repeated

Here 1->2->4->3->6->8->3->1 is a circuit

Circuit is a closed trail. These can have repeated vertices only.

**4. Path –**

It is a trail in which neither vertices nor edges are repeated i.e. if we traverse a graph such that we do not repeat a vertex and nor we repeat an edge. As path is also a trail, thus it is also an open walk.

Vertex not repeated

Edge not repeated

Here 6->8->3->1->2->4 is a Path

**5. Cycle –**

Traversing a graph such that we do not repeat a vertex nor we repeat a edge but the starting and ending vertex must be same i.e. we can repeat starting and ending vertex only then we get a cycle.

Vertex not repeated

Edge not repeated

Here 1->2->4->3->1 is a cycle.

Cycle is a closed path. These can not have repeat anything (neither edges nor vertices).

Note that for closed sequences start and end vertices are the only ones that can repeat.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- Mathematics | Euler and Hamiltonian Paths
- Mathematics | Graph Theory Basics - Set 1
- Mathematics | Graph Isomorphisms and Connectivity
- Mathematics | Graph Theory Basics - Set 2
- Mathematics | Matching (graph theory)
- Mathematics | Planar Graphs and Graph Coloring
- Mathematics | Graph theory practice questions
- Number of Walks from source to destination
- Asynchronous Sequential Circuits
- Combinational and Sequential Circuits
- Combinational circuits using Decoder
- Construction of Combinational Circuits
- Introduction of Sequential Circuits
- Classifications of Combinational and Sequential circuits
- Analysis and Design of Combinational and Sequential circuits
- Difference between Synchronous and Asynchronous Sequential Circuits
- Difference between Characteristics of Combinational and Sequential circuits
- Computer Organization | Different Instruction Cycles
- Regular Graph in Graph Theory
- Differences between Data paths

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.