Cycle:- cycle is a path of edges and vertices wherein a vertex is reachable from itself. or in other words, it is a Closed walk.
Even Cycle:- In which Even number of vertices is present is known as Even Cycle.
Odd Cycle:- In which Odd number of Vertices is present is known as Odd Cycle.
Given the number of vertices in a Cyclic Graph. The task is to determine the Number of colors required to color the graph so that No two Adjacent vertices have the same color.
If the no. of vertices is Even then it is Even Cycle and to color such graph we require 2 colors.
If the no. of vertices is Odd then it is Odd Cycle and to color such graph we require 3 colors.
Input : vertices = 3 Output : No. of colors require is: 3 Input : verices = 4 Output : No. of colors require is: 2
Example 1: Even Cycle: Number of vertices = 4
Color required = 2
Example 2: Odd Cycle: Number of vertices = 5
Color required = 3
No. of colors require is: 3
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.
- Edge Coloring of a Graph
- Graph Coloring | Set 1 (Introduction and Applications)
- Graph Coloring | Set 2 (Greedy Algorithm)
- Mathematics | Planar Graphs and Graph Coloring
- Detect cycle in the graph using degrees of nodes of graph
- Degree of a Cycle Graph
- Count of all cycles without any inner cycle in a given Graph
- Detect cycle in an undirected graph using BFS
- Detect cycle in an undirected graph
- Detect Cycle in a Directed Graph using BFS
- Detect Cycle in a Directed Graph
- Detect Cycle in a directed graph using colors
- Check if there is a cycle with odd weight sum in an undirected graph
- Shortest cycle in an undirected unweighted graph
- Find minimum weight cycle in an undirected graph
- Print negative weight cycle in a Directed Graph
- Number of single cycle components in an undirected graph
- Detect a negative cycle in a Graph | (Bellman Ford)
- Total number of Spanning trees in a Cycle Graph
- Check if a cycle of length 3 exists or not in a graph that satisfy a given condition
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.