I have a shortest-path problem and not sure what the right approach would be.
Given a tree, I would like to find the path and the path cost between two nodes, where the cost differs depending on the direction of traversal.
For example if A is a child node of B, A->B could have a cost of 3 and B->A has a cost of 4.
Is there a Java library where I can model this problem by setting up a graph with nodes and path costs in different directions as defined above, and have a way to get the path and path cost between two nodes?
There is a single path between each pair of nodes in a tree. Thus it doesn't really matter if prizes differ in the two directions - find the single path and then compute its prize in the two directions. Note that what you have is not a shortest path problem - you have a single path .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.