0

Suppose I have a directed graph with weights on each node. The weight of a path between any two nodes is defined as the following: sum of all nodes in the path and multiply by the number of nodes in that path.

We want to find a vertex-disjoint path cover that has the maximum sum of weights of all the paths in that cover.

I know this is a NP problem. Is there any algorithm that solve this problem? Or is there any problem that reduce to this problem?

YUE SHE
  • 3
  • 1

1 Answers1

0

There's an O(3^n poly(n))-time algorithm. The steps are

  1. Find all sets of vertices that can be arranged in a path.
  2. Solve the resulting set packing problem.

Step 1 is accomplished by a dynamic program whose table is indexed by pairs consisting of (a) the set of vertices in the path (b) the first vertex in the path. Step 2 is also accomplished by a dynamic program, with a table mapping sets of vertices to the maximum value attainable by disjoint paths on that subgraph.

The recurrence for Step 1 is

IsPath({v}, v) = true (for all vertices v)
IsPath(S, v) = exists w in S - {v} such that v->w is an arc and IsPath(S - {v}, w) (for all sets of vertices S, for all v in S).

Now gather all sets P such that there exists v in P such that IsPath(P, v). Compute the score for each of these paths.

BestCover({}) = 0
BestCover(S) = max Score(P) + BestCover(S - P) over all P subset of S such that P is a path (for all nonempty S).
David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • Could you elaborate on how to solve part 2? what I meant is to find the cover that has the maximum weight(sum of weights of the paths that it covers). It seems that you are finding the path that has the maximum weight? – YUE SHE Nov 21 '16 at 01:36
  • @yue I put in the recurrences. – David Eisenstat Nov 21 '16 at 15:01