How to color the verteces of triangles in different colors?

166 Views Asked by At

I have a directed graph $G=(V_n, E)$, where $V_n =\{1,2,..., n\}$ is the set of vertices and $E$ is the set of edges.

I have found the set of triangles which looks like:

  #   A    B    C
 1    7   21   24
 2    8   10   13
 3    2    8   13
 4   14   19   25
 5   18   20   24
 6   20   21   24
 7    7   20   21
 8    7   20   24
 9    5   20   24

Here $A$, $B$, $C$ are id's of the vertex in the $k$-th triangle.

I need to use a minimum number of colors to color the verticies of triangles in different colors.

My attempt is:

There are three situations for two triangles:

1) Triangles #1 (7,21,24) and #2 (8,10,13) don't have the common vertex and I can use two colors.

2) Triangles #5 (18,20,24) and #7 (7,20,21) have the common vertex 20 and I can use two colors.

3) Triangles #7 (7,20,21) and #8 (7,20,24) have the two common vertices 7, 20 and I can use two colors.

enter image description here

Question. Which is an algorithm one can use to solve this vertex coloring task?

Edit. The close task on the edge's set is here https://stackoverflow.com/questions/40432322/color-each-edge-in-triangle-igraph