Consider the following Directed graph with Node and Edge Weights.
Is there a non NP-Hard algorithm to find out the path of maximal score, where
score = sum(node weights) - sum(edge weights)
For the example graph, maximal score path is along path A -> B -> C -> D. Maximal score being 164 ((77 + 27 + 32 + 84) - (44 + 12 + 0)).
I think that there isn't any algorithm that can find the solution in polynomial time, I'm trying to prove that this problem is NP-Hard because we can reduce it to the longest path problem and the longest path problem can be reduced to it.
Here's my attempt (assuming that both edge and node weights are positive):
This problem can be reduced to the longest path problem by splitting each node A into two nodes A-IN and A-OUT, such that these nodes doesn't have any weights, we link incoming edges to A into A-IN, and outgoing edges from A to A-OUT, and add an edge between A-IN and A-OUT with weight equal to -1 times node A's original weight. Now to find a solution to the problem you have to find the longest path in this graph.
The longest path problem can be reduced to this problem by taking each negative weight edge E between two nodes A and B and create a virtual node AB in the middle of it, we remove E from the graph then add an edge from A to AB with weight 0, and an edge from AB to B with weight 0, and give node AB weight equal to -1 times the weight of the original E.
So that was hopefully a proof that you can solve the longest path problem by reducing it to your problem, so if there is a polynomial time solution to your problem then P = NP.