Replacing old version graphshortestpath with new shortestpath function

10 ビュー (過去 30 日間)
Jeff Boker
Jeff Boker 2022 年 11 月 30 日
コメント済み: Walter Roberson 2023 年 10 月 12 日
I am using source code from an old repo and I am trying to replace their graphshortestpath() function with the newer shortestpath(). I went through both documentations and the inputs are graph, source, and target.
Currently, this is the line of code that is undefined since graphshortestpath() does not exist in matlab:
[ dist,path{1} ] = graphshortestpath( adjMatrix, 1, numel(newImg(:)));
The inputs are adjMatrix is 10710x10710 double (sparse), and newImg is 105x102 double. I tried replacing graphshortestpath() with shortestpath() and matlab still says the function is undefined.
Undefined function 'shortestpath' for input arguments of type 'double'.
Error in getHyperReflectiveLayers (line 68)
[ dist,path{1} ] = shortestpath( adjMatrix, 1, numel(newImg(:)));

回答 (3 件)

TENG LIU
TENG LIU 2023 年 10 月 12 日
編集済み: TENG LIU 2023 年 10 月 12 日
Are you trying to use the Caserel segmentation code?
I have a solution for those bugs (It is truly annoying for the removal of the old code),
The commented part is the old code, the newer in the below:
% [ dist,path{1} ] = graphshortestpath( adjMatrix, 1, numel(newImg(:)));
path{1} = shortestpath(graph(adjMatrix,'upper'), 1, numel(newImg(:)));
GLHF!

Catalytic
Catalytic 2022 年 11 月 30 日
編集済み: Catalytic 2022 年 11 月 30 日
I tried replacing graphshortestpath() with shortestpath() and matlab still says the function is undefined.
A strange thing to do. What are the odds that the shortestpath() command would have the exact same input syntax as some arbitrary 3rd party function?
[ dist,path{1} ] = shortestpath( graph(adjMatrix), 1, numel(newImg(:)));
  3 件のコメント
TENG LIU
TENG LIU 2023 年 10 月 12 日
Not only the graphshortestpath is removed by MatLab, the biograph is also removed by Matlab recently (2022b looks like).
Steven Lord
Steven Lord 2023 年 10 月 12 日
Yes, the biograph object was removed in release R2022b according to the Bioinformatics Toolbox Release Notes. We started warning (in the Release Notes and in the documentation) about the impending removal starting in release R2021b. The graph and digraph classes that supersede it were introduced in release R2015b.
As stated on that Release Notes page, most if not all of the functionality that biograph provided is also provided by the graph and/or digraph objects in core MATLAB. There is one item in that table that is kind of missing: a replacement for dolayout is specifying the Layout name-value argument when you plot the graph or digraph or to call the layout function on the graphics handle returned by plot when called with a graph or digraph input.
If there is functionality that you were able to use with biograph that you cannot do with graph or digraph please let us know.

サインインしてコメントする。


Christine Tobler
Christine Tobler 2023 年 10 月 12 日
You can replace
[ dist,path{1} ] = graphshortestpath( adjMatrix, 1, numel(newImg(:)));
with
[ path{1}, dist ] = shortestpath( digraph(adjMatrix), 1, numel(newImg(:)));
in your code. If the graph being defined by adjMatrix is undirected, you can instead call graph(adjMatrix) - the default of graphshortestpath was to assume a directed graph, but if adjMatrix is symmetric both methods have the same behavior.
  1 件のコメント
Walter Roberson
Walter Roberson 2023 年 10 月 12 日
numel(newImg(:)) should be the same as numel(newImg)
(For all but some very odd class redefinitions of subsref or using matlab.mixin.indexing.RedefinesParen class )

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by