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
- Edge Coloring of a Graph
- Graph Coloring | Set 2 (Greedy Algorithm)
- Graph Coloring | Set 1 (Introduction and Applications)
- Mathematics | Planar Graphs and Graph Coloring
- Detect cycle in the graph using degrees of nodes of graph
- Degree of a Cycle Graph
- Detect cycle in an undirected graph using BFS
- Detect Cycle in a Directed Graph using BFS
- Detect Cycle in a Directed Graph
- Detect cycle in an undirected graph
- Check if there is a cycle with odd weight sum in an undirected graph
- Detect Cycle in a directed graph using colors
- Shortest cycle in an undirected unweighted graph
- Number of single cycle components in an undirected graph
- Find minimum weight cycle in an undirected graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.