Suppose I had this Directed Acyclic Graph (DAG), where there is a directed edge from each node (other than the nodes in the bottom row) to the two nodes below it:
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
I need to find a path through this DAG where the sum of the nodes' weights is maximized. You can only move diagonally down-left or down-right from a node in this tree. So for example, 7, 3, 8, 7, 5, would give the maximum path in this tree.
The input file contains the DAG formatted in this way
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
My question is, what algorithm would be best to find maximum path and also how would this tree be represented in C++?
The node weights are non-negative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With