I want to create a 2D diagram like the following,
The above image has been created using Graph
in MATLAB (ref)
s = [1 1 1 1 2 2 3 4 4 5 6];
t = [2 3 4 5 3 6 6 5 7 7 7];
weights = [50 10 20 80 90 90 30 20 100 40 60];
G = graph(s,t,weights)
plot(G,'EdgeLabel',G.Edges.Weight)
The information is stored as nodes, edges, edge weight of a graph
.
I'd like to create a 2D CAD drawing using this information. The length of lines can be specified using edge weights. However, I am not sure how the angles can be retrieved from the graph. From what I understand, the orientation of the edges vary depending on the layout that is selected for creating a graph object.
I want to create a [x,y] coordinate file and import into Autocad.
EDIT: From the answer explained below, I understand it is not straightforward to assign the edge weights as lengths. As an alternative, I want to obtain the coordinates of nodes from the image, compute the distance between nodes and assign the distance as edge weights (ignoring the weights provided above). With the set of coordinates, node-node connection and node-node distance I'd like to generate a 1D CAD digram programmatically.
EDIT2:
Since the coordinates of the nodes cannot be directly obtained from the MATLAB output and the edge weights(in the original input) cannot be assigned as edge lengths, I'd like to try an alternate approach.
For instance, if these are the coordinates of the nodes ((75 25) (115 45) (90 60) (10 5) (45 0) (45 55) (0 25))
, I'd like to compute the euclidean distance between
the coordinates and assign the distances as edge weights.
From what I understand, the dimension
tab in AutoCAD computes the euclidean distance. However, I am not sure how to assign this output as edge weights.
Any suggestions on how to proceed will be really appreciated.