2 problem with minspantree.m in Matlab 2018a

1 回表示 (過去 30 日間)
Tiger Zhao
Tiger Zhao 2018 年 12 月 29 日
コメント済み: Tiger Zhao 2019 年 1 月 11 日
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:
  1. 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?
  2. 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.

採用された回答

Christine Tobler
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
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?
Tiger Zhao
Tiger Zhao 2019 年 1 月 11 日
Hi Christine Tobler,
Thank you for your enthusiasm.
For example, There is a dynamic adjacent matrix, which means the graph is changing over time. The dimension of this dynamic adjacent matrix is P*P*N, where N could be very large.
So at every time point i, N=i, find the MST, calculate the MST's adjacent matrix, save them.
Of couse, I could do this using graph object. But it's a little bit slow. I tried both method. The both IN an OUT are matrix method is faster.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by