Question

My question is similar to finding smallest path (Dijkstra's Algorithm), but instead of shortest path, I want to find the largest product of all edges on the one from one node to any other.

Given all edges are positive weighted and each node is bi-directional connected with adjacent nodes, my understanding is that implementation of such algorithm is just the opposite to finding shortest path. but I am not sure if what i'm thinking is correct, and can anyone suggest where I should start with in C# ? ?

To give an example of bidirectional conncetion:

Node: A,B Weight: A->B =2;B->A=1/2

so the weight of edges for one node is always reciprocal

Was it helpful?

Solution

All weights are positive, right?

  1. Replace each weight W with log(1/W).

  2. Run the Bellman-Ford algorithm, which is the extension of Dijkstra for graphs with negative weights.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top