How to generate a connection graph with vertices and edges

조회 수: 16 (최근 30일)
Vinit Nagda
Vinit Nagda 2021년 7월 19일
댓글: Vinit Nagda 2021년 7월 19일
I want to generate a connection graph as shown in the figure above. I have the 3D points (vertices/dots in the figure). I want to run a condition check for each pair of vertices and draw the line segments (edges) connecting the vertices if the condition is true. Can someone please help me with proper functions in the pseudo code below to draw line segments and display the final 3D connection graph? Thank you.
Pseudo code:
P=vertices; (points, nx3)
for i=1:size(P,1)
for j=i+1:size(P,1)
if condition for vertices 'i' and 'j' is true:
connect the vertices with line segment
end
end
#display final connection graph with vertices and edges

채택된 답변

Matt J
Matt J 2021년 7월 19일
I don't know if you even need a for-loop. You should probably just build a graph object using one of the syntaxes listed in the documentation
  댓글 수: 2
Steven Lord
Steven Lord 2021년 7월 19일
And if you do create a graph object you can specify node coordinates when you call plot on that graph, as shown in the "Custom Graph Node Coordinates" on this documentation page.
Vinit Nagda
Vinit Nagda 2021년 7월 19일
Thank you for your responses and for sharing the relevant links for graph object documentation. I was able to plot the connection graph figure using the "Custom Graph Node Coordinates".
Thank you for the support.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by