Page 1 of 1

calculates a set of nodes

Posted: Wed May 06, 2009 8:26 pm
by nicoletsg
In a direct graph calculates a set U of nodes (u maximal) such there is a path (not necessarily simple) that passes via all U nodes .
Can anyone suggest to which broader category of algorithms this problem can belong to

Re: calculates a set of nodes

Posted: Wed May 06, 2009 9:53 pm
by mf
In a direct graph calculates a set U of nodes (u maximal) such there is a path (not necessarily simple) that passes via all U nodes .
You want to find a (not necessarily simple) path in a directed graph which visits the largest number of distinct vertices in this graph?

Find strongly connected components, shrink each SCC into a vertex with weight equal to SCC's size, and then find the longest path in resulting graph using dynamic programming. DP works because this graph is always acyclic (it's called strong components DAG). Then "un-shrink" each SCC on the found path by visiting all its vertices in any order.