Masoudvahid / NP-Algorithm-Graph-Coloring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NP-algorithm-Graph-Coloring

The link to the presentation

The problem to find chromatic number of a given graph is NP Complete.
Actually, there is no efficient algorithm available for coloring a graph with minimum number of colors as the problem is a known NP Complete problem There are approximate algorithms to solve the problem though.

The following pictures will show the concept of graph coloring

  • Chromatic = 4

  • Chromatic = 2


Time complexity

The time complexity of graph coloring using greedy algorithm is O(V^2 + E) in the worst case, and here is the proof.

And if we use adjacency matrix, the time complexity would be O((n+1)! and here is the required documentation


Algorithms for coloring a graph

There exists some ways for solving this problem

Greedy Algorithm

even though it doesn’t guarantee to use minimum colors, but it guarantees an upper bound on the number of colors. The basic algorithm never uses more than d+1 colors where d is the maximum degree of a vertex in the given graph.

Adjacency matrix

what is adjacency matrix?
The Adjacency matrix is a simple and straightforward way of representing a graph G= (V, E) on n = |V| vertices, labeled 1, 2, …, n is by using an n by n matrix.

for example:

Algorithm

  1. Find all the symmetric edges in one representation of (i, j) and (j, i).
  2. Give each vertex one color for initialization.
  3. For coloring, visit each vertex and check each adjacent vertice connected on that vertex if the color is the same as the current vertex and adjacent vertex. If the colors are the same, then change the color. Like the following picture:

About

License:MIT License


Languages

Language:Python 100.0%