1

I have a directed graph (DAG) containing many nodes, all with various attributes (node attributes not edge attributes). I have a single target (finish) node and a set of source (start) nodes. I want to find a path through this graph that minimizes the sum of all the attributes on said path, and return the top N minimized paths .

Example: the nodes are tasks in a to-do list. Some items on the list need to be completed before others can be started. In this example, an attribute could be the 'spare time' or 'wiggle room' an item has before its delay would have a knock-on effect and delay the next item. So I want to find the path that minimizes the total 'spare time'. i.e. the most optimal way of working through the task from A to B.

I considered using Dijkstra's algorithm where I replace the distance parameter with the node attribute I wish to minimize. However, I am not sure how this would work as I only have node attributes, not edge attributes. I could set the edge attribute to be that of the source, or target nodes for that edge, but I don't think this is valid. E.g. if using the source node attribute for the edge attribute, then the final node in the chain's attribute would never be used and vice versa. Additionally, the actual path length doesn't matter, just the sum of the attributes along the path.

Finally, another issue is that the attributes along the path that I am trying to minimize can be negative, so the minimized path sum can be negative or positive. This seems to rule out a BFS or DFS method with early stopping (threshold) as it could stop before a future negative attribute has been reached, which would decrease the total sum along the path.

Any help or suggestions would be great, thanks.

laurence
  • 11
  • 2

2 Answers2

1

Produce graph H by replacing each node $v_i$ with two nodes $I_i$ and $O_i$ and an arc $(I_i,O_i)$ between them, where input arcs to original node $v_i$ be as input arcs to new node $I_i$ and output arcs from original node $v_i$ be as output arcs from new node $O_i$.

Assign attribute weight of original node $v_i$ to the arc $(I_i,O_i)$ and assighn zero weights to all other arcs (i.e. input/output arcs of the original graph).

Now, it is sufficient to find the shortest path from source node to target node.

As long as the graph H does not have a negative cycle the problem is easy to solve.

0

It's NP-hard with a single source and a single target, and looking for a single path.

Reduction from SAT. Let $\phi = C_1 \land C_2$ where $C_1 = x \lor y$ and $C_2 = \neg x \lor y$.

See attached picture. There is a path collecting exactly #variables many attributes if and only if $\phi$ is satisfiable.

In the example, you can find an $s$-$t$-path collecting exactly two attributes, the ones corresponding to your chosen truth assignment. Notice that if you in the start choose to visit $\neg y$, you need to visit three attributes.

Reduction from SAT

Ainsley H.
  • 17,823
  • 3
  • 43
  • 68