Hi, I have tried to use digraph on a Matlab2016 version.
However the result is: Error using digraph/subsref Method 'subsref' is not defined for class 'digraph' or is removed from MATLAB's search path.
Error in name of program (line 117) plot(G,'Layout','force','EdgeLabel',G.Edges.Weight,'markersize',20)
Warning: Function subsasgn has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
thanks

2 件のコメント

Walter Roberson
Walter Roberson 2017 年 9 月 11 日
Please show us the output of
which plot
I suspect you have created a variable named "plot"
Stephen23
Stephen23 2017 年 9 月 12 日
Please show us the output of these commands:
which plot -all
which subsasgn -all

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

 採用された回答

Guillaume
Guillaume 2017 年 9 月 11 日
編集済み: Guillaume 2017 年 9 月 11 日

0 投票

Is there actually a Weight column in your edge table? If you haven't specified a weight of any edge, the Weight column is never created.
I can easily reproduce a similar error in R2017a if the graph does not have weights for the edges. In R2017a, the error message is a bit more detailed:
>> G = digraph([1 1], [2 3]);
>> plot(G,'Layout','force','EdgeLabel',G.Edges.Weight,'markersize',20)
Error using digraph/subsref (line 27)
Unrecognized variable name 'Weight'.
>> G.Edges
ans =
2×1 table
EndNodes
________
1 2
1 3
However,
>> G = digraph([1 1], [2 3], [5 3])
>> plot(G,'Layout','force','EdgeLabel',G.Edges.Weight,'markersize',20)
>> G.Edges
ans =
2×2 table
EndNodes Weight
________ ______
1 2 5
1 3 3
No error

4 件のコメント

economics student
economics student 2017 年 9 月 12 日
編集済み: Guillaume 2017 年 9 月 12 日
Hi, many thanks. This is what i have:
ss=[];
tt=[];
weights=[];
for i=1:N
for j=1:N
if Deltatnet(i,j)>0
ss=[ss,i];
tt=[tt,j];
weights=[weights,Deltatnet(i,j)];
end
end
end
Guillaume
Guillaume 2017 年 9 月 12 日
And how do you create the graph from that? with?
G = digraph(s, t, weights)
if so, I don't know what the problem is unless you've named a variable or function the same as plot, subsref or other important matlab function.
Unrelated to your immediate problem, you're using the most inefficient method to build your graph. You can just pass your weighted adjacency matrix directly to digraph:
G = digraph(deltatnet);
Even if you wanted to build the edge and weight lists prior to creating the graph, you could do it a lot more efficiently in just one line:
[ss, tt, weights] = find(Deltatnet);
economics student
economics student 2017 年 9 月 12 日
編集済み: Walter Roberson 2017 年 9 月 12 日
The graph is created like this:
G = digraph(ss,tt,weights,names);
plot(G,'Layout','force','EdgeLabel',G.Edges.Weight,'markersize',20)
axis equal off
economics student
economics student 2017 年 9 月 12 日
Hi, thanks again. I have reloaded the program and it seems to work out for some reason. Will certainly take note of your suggestions as well. Best regards.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by