# Setting Edge Lengths equal to Weights in 2015B+ for graph.m

3 visualizaciones (últimos 30 días)
Matlab2010 el 11 de Mzo. de 2016
Editada: Matlab2010 el 14 de Mzo. de 2016
In 2015B graph.m is introduced graph.m.
s = [1 1 1 2 2 3 3 4 5 5 6 7];
t = [2 4 8 3 7 4 6 5 6 8 7 8];
weights = [10 10 1 10 1 10 1 1 12 12 12 12];
names = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
G = graph(s,t,weights,names)
plot(G);
h=get(gca, 'Children');
When matlab plots the graph, all the edges are approximately the same length (they are approx as matlab does the plotting to ensure labels are not obstructed).
Question 1 How do I set the edge lengths to be equal to the weights?
Question 2 How can I plot in 3D using a Cartesian coordinate system? I assume there are some assumptions I would need to make in order to allow this.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Steven Lord el 14 de Mzo. de 2016
I don't think any of the existing layout methods will determine the coordinates automatically, and in some cases that would be an impossible task. Consider a graph with three vertices, where the weights on edges (1, 2) and (1, 3) are both 1 but the weight on edge (2, 3) is 3. By the triangle inequality you can't draw this triangle with straight edges.
If you can compute the coordinates yourself you can set the XData and YData properties of the plot object. If you want to have a layout method that can compute those coordinates automatically, contact Technical Support and submit that as an enhancement request.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Line Plots en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by