Select vertex on DAG and ensure topological sorting depth in limit

24 Views Asked by At

Given a directed acyclic graph, some node's indegree are zero. I want to select some other nodes and set their indegree to zero mannual, then perform topological sorting on the directed graph and ensure that the topological sorting depth of all nodes are less than 'k'. How to select the smallest number of nodes(set indegree to zero)? Means maximizing the number of remaining nodes?

I use dfs to traverse graph. If one node topological sorting depth is greater than k, then set this node to in-degree zero, but this is not guaranteed to be the optimal solution.

Thanks in advance.

0

There are 0 best solutions below