LONGEST PATH BY PRODUCT

조회 수: 5 (최근 30일)
Lala
Lala 2020년 1월 12일
댓글: Lala 2020년 1월 26일
Hello,
I have an adjacency matrix (A= [0,0,0.6,0.7,0.3;0.9,0,0,0.3,0;0,0.6,0,0.9,0;0,0,0.4,0,0.9;0,0,0,0,0]) that represents the weights of edges on a 5 node graph, and I wish to find the longest (by product not sum) between two nodes. I was considering doing an element by element inverse of the matrix (1./A) then I would go ahead and apply the Dijkstra's algorithm but using this method would give me the longest path (due to the inverse funtion) based on summation, where as I need the longest path based on multiplication.
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 1월 12일
log() so sum of logs and exp() to get the product
Lala
Lala 2020년 1월 26일
Thank you

댓글을 달려면 로그인하십시오.

채택된 답변

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 1월 12일
You can take the log of your inverse matrix and use the log property:
Which basically says that maximizing/minimizing the sum (of logs) is the same as maximizing/minimizing the product of the variables.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dijkstra algorithm에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by