Baszyk
Baszyk

Reputation: 11

sna: modification of the Dijkstra algorithm (shortest paths)

I've been using the function shortest_paths from the igraph package in order to calculate the shortest path between two links.

My igraph object contains the weighted links.

The integrated Dijkstra algorithm uses sums in order to express the shortest path.

How can I use the product instead of the sum?

Upvotes: 1

Views: 349

Answers (1)

Ryan Haunfelder
Ryan Haunfelder

Reputation: 786

Log is a monotonically increasing function so the path that minimizes the product of the edge weights will also minimize the log of the product of the edge weights, or equivalently the sum of the log of the edge weights. Therefore, you can just replace the edge weights with their log transformation and use the shortest path function.

Upvotes: 3

Related Questions