How can I save my variable of type graph into a file?

1 回表示 (過去 30 日間)
Asaf McRock
Asaf McRock 2021 年 2 月 14 日
コメント済み: Asaf McRock 2021 年 2 月 14 日
Hello,
I'm trying to save the content of variable GG into an ASCII format file but I'm getting the following error
Error using graph/subsref (line 7)
Indexing not supported.
Error in dlmwrite (line 166)
rowIsReal = isreal(m(i,:));
so=[1 1 1 2 2 2 2 3 3 3 5];
ta=[2 3 4 3 4 5 6 6 7 5 7];
GG=graph(so,ta);
dlmwrite('graph.txt',GG)
Could you please teach me how to avoid this error?

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 14 日
dlmwrite('graph.txt',GG.Edges.EndNodes)
However in general there can be additional attributes associated with a graph, and you might want to
dlmwrite('graph.txt', table2array(GG.Edges))
  6 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 14 日
dlmwrite has an append option, but dlmwrite is really only for numeric data.
Asaf McRock
Asaf McRock 2021 年 2 月 14 日
It seems that writetable doesn't have an append option. Will it be efficient to save Nodes and Edges in two different files?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by