Design & Analysis
Of Algorithms
z
Topic: 1.Graph Coloring
2.Hamiltonian Circuit Problem
Presenters: Roll no Name
169 Sirshendu
Ghorai
170 Sneha Das
171 Snigdhendu
Chatterjee
172 Sohom Date: 20.05.24
z
Introduction
Definition of Algorithms: Sequence of steps for
solving a problem.
Importance: Algorithms are fundamental to computer
science.
Focus: Significance of graph coloring and Hamiltonian
circuits.
z
What is Graph Coloring?
Graph coloring refers to the problem of coloring
vertices of a graph in such a way that no two
adjacent vertices have the same color. This is also
called the vertex coloring problem.
Chromatic Number:
The minimum number of colors
needed to color a graph is called
its chromatic number.
Types of Chromatic Number of Graphs:
There are various types of chromatic number of graphs, which
are described as follows:
Cycle Graph:
Chromatic number:
The chromatic number in a cycle graph will be 2 if the number of
vertices in that graph is even.
The chromatic number in a cycle graph will be 3 if the number of
vertices in that graph is odd.
Planner Graph:(must not cross each other)
Chromatic Number:
In a planner graph, the chromatic Number must be Less than or equal
to 4.
The planner graph can also be shown by all the above cycle graphs
except example 3.
Complete Graph:
Chromatic Number:
In a complete graph, the chromatic number will be equal to the number
of vertices in that graph.
Bipartite Graph:
Chromatic Number:
In any bipartite graph, the chromatic number is always equal to 2.
Tree:
Chromatic Number:
In any tree, the chromatic number is equal to 2.
z
Graph Colouring Algorithms
V is the no of vertices
Greedy Coloring Algorithm E is the number of edges.
Steps:
Sort vertices by degree.
Color each vertex ensuring no adjacent vertices share the same
color.
Repeat until all vertices are colored.
Limitations: May not yield the minimum number of colors (optimal
solution).
z
Graph Colouring Algorithms
The number of vertices in
Backtracking for Graph Colouring the graph as V
How it Works: For the first vertex, there
are C choices.
Start Empty: Begin with no colors assigned to any vertex.
Assign Colors: Try coloring one vertex at a time.
Check Validity: Make sure no two connected vertices have the same color.
Backtrack if Needed: If you find that a vertex cannot be colored without breaking
the rules, go back and change the color of the previous vertex.
Repeat: Continue this process until the whole graph is colored correctly or all
possibilities are exhausted.
Why It's Hard:
Complexity: The problem is NP-complete, meaning it is very difficult and time-
consuming to find the best solution, especially as the number of vertices
increases.
Optimization: Finding the minimum number of colors needed can be challenging.
z
Applications of Graph Coloring:
• Design a timetable.
• Sudoku.
• Register allocation in the compiler.
• Map coloring.
• Mobile radio frequency assignment.
Conclusion
Graph coloring is a crucial and widely applicable problem in computer science,
involving the assignment of colors to graph vertices such that no two adjacent
vertices share the same color. Despite its straightforward definition, the problem
is NP-complete, posing significant challenges for finding optimal solutions in large
graphs. Various algorithms, from greedy approaches to backtracking, offer
different trade-offs between efficiency and accuracy. While exact solutions can be
computationally expensive, practical applications often rely on heuristics and
approximations to achieve satisfactory results.
Hamiltonian Circuit Problem
Definition: A cycle that visits every vertex exactly once and returns to the start.
The Hamiltonian cycle/circuit problem is similar to the Hamiltonian path problem, except
it asks if a given graph contains a Hamiltonian cycle. This problem may also specify the
start of the cycle. The Hamiltonian cycle problem is a special case of the travelling
salesman problem, obtained by setting the distance between two cities to one if they are
adjacent and two otherwise, and verifying that the total distance travelled is equal to n. If
so, the route is a Hamiltonian cycle.
Backtracking Approach to
Hamiltonian
Definition:
Circuit
Systematically explores potential circuits and abandons paths that
cannot possibly lead to a solution.
Steps:
Start with an initial vertex.
Add adjacent vertices one by one, ensuring no vertex is visited more
than once.
If stuck, backtrack to the previous vertex and try a different path.
Check if the final vertex connects back to the starting vertex to
complete the circuit.
Algorithm: N is the no of vertices
Start with an empty path.
Add a vertex to the path.
Recursively extend the path.
If adding a vertex violates the Hamiltonian property, backtrack.
Continue until a valid circuit is found or all possibilities are
exhausted.
CONCLUSION
Hamiltonian Circuit Problem: Investigating the quest for Hamiltonian cycles has revealed the
complexity of finding optimal routes visiting every vertex exactly once. The backtracking method
offers a systematic exploration, albeit with its own exponential time challenges.
Challenges and Future Directions: NP-completeness underscores the inherent complexity of these
problems, inviting further exploration into optimization techniques, approximation algorithms, and
emerging technologies like quantum computing.
In this journey through graph coloring and Hamiltonian circuits, we have witnessed the intricate
interplay between theoretical complexity and practical utility, underscoring the enduring significance
of these fundamental problems in computer science.
THANK YOU