Merge adjacent vertices of the graph until one single vertex remains at the minimum distance

I have a game system that can be represented as an undirected, unweighted graph, where each vertex has one (corresponding) property: color. The goal of the game from the point of view of the graph is to reduce it to one vertex in the least number of "steps". At each step, the player can change the color of any one vertex, and all adjacent vertices of the same color merge with it. (Note that in the example below it just seemed to me that the user changes only one specific vertex for the whole game, but the user can select any vertex at each step.)

graph chart

What I need is a way to calculate the smallest number of steps needed to β€œbeat” a given schedule in accordance with the procedure described above, as well as provide the specific steps necessary for this. I am familiar with the basics of finding paths, BFS, and things of this nature, but it's hard for me to find this problem in terms of solving the β€œfastest way”.

I cannot find this problem anywhere on Google or even the term graph theory that encapsulates the problem. Does anyone have an idea, at least, how to get started with this problem? Can someone point me in the right direction?

* , -, , , . - , , ? ( , , , 20 .) , BFD ... , , , . ?

+4
3

, . , , , , , ..

, , . - , - . , , , , . , .

+2

, .

, , . . A , A.

, , (S), S. supersequence, NP-complete.

, : -/

* . .

>= . :

  • ,
  • , , , , "" .

, . - , . , BFS , . , , . , , , .

+2

I think the graph you are looking for is the "valency" of the graph, which is the number of edges that the node is connected to. It looks like you want to change the color based on the fact that node has the highest valency. Then, in the resulting graph, change the color for the node that has the highest valency, etc., until you leave only one node.

+1
source

Source: https://habr.com/ru/post/1677570/


All Articles