필터 지우기
필터 지우기

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 CenterFile Exchange에서 Undirected Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by