フィルターのクリア

How can I generate a square lattice undirected graph?

13 ビュー (過去 30 日間)
Rayan Glus
Rayan Glus 2021 年 10 月 14 日
コメント済み: Rayan Glus 2021 年 10 月 15 日
Hi,
How can I generate a square lattice undirected graph? I tried this:
n = 10;
A = delsq(numgrid('S',n+2));
G = graph(A,'omitselfloops');
plot(G)
But the links do not look straight, right? And the graph looks like a plateau.
Thanks!
  1 件のコメント
Rayan Glus
Rayan Glus 2021 年 10 月 14 日
編集済み: Rayan Glus 2021 年 10 月 14 日
Okay, when I checked the XData and YData using :
p = plot(G);
p.XData
p.YData
I found that nodes are not evenly spaced. Can you help me on this please?

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

採用された回答

Chunru
Chunru 2021 年 10 月 15 日
n = 10;
A = delsq(numgrid('S',n+2));
G = graph(A,'omitselfloops');
h = plot(G);
h.XData = floor((0:99)/10);
h.YData = rem((0:99), 10);
axis equal

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by