computing "node closure" of graph with removal
- by Fakrudeen
Given a directed graph, the goal is to combine the node with the nodes it is pointing to and come up with minimum number of these [lets give the name] super nodes.
The catch is once you combine the nodes you can't use those nodes again. [first node as well as all the combined nodes - that is all the members of one super node]
The greedy approach would be to pick the node with maximum out degree and combine that node with nodes it is pointing to and remove all of them. Do this every time with the nodes which are not removed yet from graph.
The greedy is O(V), but this won't necessarily output minimum number super nodes.
So what is the best algorithm to do this?