3

There are N vertices and M edges in the world. There are three types of edges: type "AB", "BC", and "CA".

There are three people A, B, and C. Each person can use an edge if and only if its type name contains the person's name. (For example, A can use edges with type AB and type CA)

I'd like to select some edges so that for all people, the graph is connected. As a result, if we make a graph consisting of edges with type AB and type CA, this graph should be connected. (This should also hold with type AB/BC, BC/CA)

How should I solve this problem? There are two versions

  1. What if I want to minimize the number of chosen edges?
  2. What if I want to minimize the total cost of chosen edges?

This is what I've tried.

Mainly, it is really good to add an edge with type 'XY' if it connects both of the graphs for X and Y. So, first add all the edges which is really good, and then add some edges which connects at least a graph for one person.

  • This might be a good solution if I shuffle the order of edges infinitely, but I'm not sure with this, and it cannot solve the second problem.

  • I have some greedy strategy: First make a connected graph for A with minimum number (or cost) for A, and then for B, and next C. Shuffle the order of people (so the algorithm will be applied 6 times)

I have a strong feeling that this problem is NP-hard, but cannot change the problem to a well-known NP-hard problem..

K.R.
  • 31
  • 3
  • Welcome to Stackoverflow. Please remember we can help you solve specific coding problems, but we can't do your homework. What have you tried so far? Do you have any code to show? – evolutionxbox Aug 10 '15 at 12:32
  • OK. Actually I was inspired by this problem: https://www.hackerearth.com/code-monk-minimum-spanning-tree/algorithm/3-types/ – K.R. Aug 10 '15 at 12:35
  • I'll write what I've tried in the question. Please wait a bit – K.R. Aug 10 '15 at 12:35
  • @evolutionxbox, added my thoughts about the problem. Please give me some advice, I'm a novice :D – K.R. Aug 10 '15 at 12:40

0 Answers0