List of digraphs in MATLAB

56 views Asked by At

I am a beginner in MATLAB.

I have a function that takes an integer as input and returns a directed graph (digraph); I therefore have a list of integers L, and would like to create a list of digraphs derived from such integers.

I have a function create_graph(n) that returns such digraph.

What I am currently doing is:

Gs = [];
for i=1:length(L)
   x = L(i);
   G = create_graph(x);
   Gs(end + 1) = G;
end

And it returns an error:

Unable to perform assignment because value of type 'digraph' is not convertible to 'double'.

Error in dummy_code (line 20)
    Gs(end + 1) = G;

Caused by:
    Error using double
    Conversion to double from digraph is not possible.

Another error appear if I initialize a dummy digraph, that is:

Gs = [digraph([1,1;1,1])];
for i=1:length(L)
   x = L(i);
   G = create_graph(x);
   Gs(end + 1) = G;
end
Error using indexing
Unsupported graph indexing.
 

What I would like to do is something close to the python code:

Gs = [create_graph(x) for x in L]
0

There are 0 answers