i want to make a change in "graphshortestpath" function to give bonus to edges in paths that have distance > 2
1 次查看(过去 30 天)
显示 更早的评论
[DIST,PATH,PRED] = GRAPHSHORTESTPATH(G,S) determines the single source shortest paths from node S to all other nodes in the graph G.
the result of this function "graphshortestpath" is [dist,path,pred], where dist is the distance form S"source node" to all other nodes .
i want to make change that : if dist from S to D > 2 "for un directed graph" give each edge in this path a bonus equal to 0.5. else don't make any thing
for example
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160387/image.png)
the adjecency matrix of this graph is g=[0 1 1 0 ; 1 0 1 1 ; 1 1 0 1 ; 0 1 1 0]; and the dist from node 1 to 4 is '4' ,this value > 2 , so i want to give each edge in the path from node 1 to 4 "e12 , e24 " a bonus equal to 0.5 .
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!