2 problem with minspantree.m in Matlab 2018a
1 回表示 (過去 30 日間)
古いコメントを表示
Hi dear all; I want to find a min-span-tree of a matrix. I figured that MATLAB's own minspantree.m may be the most efficient algorithm. So i use
open minspantree.m
And here comes Question:
- The code in minspantree.m used G.EdgeProperties.Weight and G.Underlying. G is a graph object. But when I use G.EdgeProperties.Weight or G.Underlying in Command window, both returns error: Error using graph/subsref (line 15) No public property 'EdgeProperties' for class 'graph'. Why?
- minspantree.m line 62:
[pred, edgeind] = primMinSpanningTree(G.Underlying, w, rootNode, restart);
Is primMinSpanningTree a function? But I can not find any: function [ ] = primMinSpanningTree() in minspantree.m, neither can I find primMinSpanningTree.m file in my whole disk. So what is primMinSpanningTree? What is its code? How can I find it and open it?
Thanks all very much.
0 件のコメント
採用された回答
Christine Tobler
2019 年 1 月 1 日
編集済み: Christine Tobler
2019 年 1 月 1 日
The properties Underlying and EdgeProperties are private properties of the graph object, which can only be accessed in methods of the graph object. The function primMinSpanningTree is a builtin method of the internal helper object that is stored in G.Underlying.
It is not recommended to use either of these directly - the recommended way is to construct a graph object and call the method minspantree for this object.
3 件のコメント
Christine Tobler
2019 年 1 月 10 日
Hi Tiger,
I just came back from vacation and saw your reply. Sorry I did not realize that your motivation for looking at minspantree.m was performance.
If you have the Bioinformatics toolbox, you could try their function graphminspantree, which takes and returns a sparse matrix.
There is also the File Exchange package MatlabBGL, which has a function mst that takes and returns a graph represented as a matrix.
If you don't mind, I would like to know more about your workflow. Why do you need to convert a graph to a matrix and back again, instead of using the graph format throughout? Are there some things you can't do with a graph, where you need to have the matrix representation available instead?
その他の回答 (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!