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
- What if I want to minimize the number of chosen edges?
- 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..