Azzera filtri
Azzera filtri

Replacing old version graphshortestpath with new shortestpath function

42 visualizzazioni (ultimi 30 giorni)
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(:)));

Risposte (3)

TENG LIU
TENG LIU il 12 Ott 2023
Modificato: TENG LIU il 12 Ott 2023
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 il 30 Nov 2022
Modificato: Catalytic il 30 Nov 2022
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 Commenti
TENG LIU
TENG LIU il 12 Ott 2023
Not only the graphshortestpath is removed by MatLab, the biograph is also removed by Matlab recently (2022b looks like).
Steven Lord
Steven Lord il 12 Ott 2023
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.

Accedi per commentare.


Christine Tobler
Christine Tobler il 12 Ott 2023
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.

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by