0

I'm trying to construct a kind of graph in matlab: For each vertex I know its neighbours (thus, I have the edge list), and the distance between vertex-neighbour. This distance is saved as weight of the edge. So, the weights are actually the physical distances between the nodes.

For now I could only associate a wider line to bigger weights but is not enough.

I actually would like having longer lines associated to a bigger weights, so that I could visually construct a suitable geometry from my data.

Any tips?

EDIT: The distances are such that the drawing is possibile.

enter image description here

Cla
  • 171
  • 1
  • 12
  • Your edge should be represented with straight lines ? – obchardon Jul 06 '20 at 13:52
  • yes, that would be better. Intuitively, if each distance (weight) is equal to the same value W, then the graph would be a regular mesh, like a simple grid. Otherwise, I would like this difference in weights to be shown with longer/shorter lines – Cla Jul 06 '20 at 13:53
  • If we have 3 vertex A,B and C and the weight A-B = 1, B-C = 1 and C-A = 3 then there is no possible representation with straight lines (at least in an euclidian space). How such a case should be treated ? – obchardon Jul 06 '20 at 14:04
  • I did add a picture to make you see an example of these drawing – Cla Jul 06 '20 at 14:27
  • If you're using MATLAB's [`graph`](https://www.mathworks.com/help/matlab/ref/graph.html) class, `plot` will do it for you, given the [right parameters](https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.graphplot.layout.html#mw_3b90f3f2-7b4f-4263-bbb3-1e4a496b9181). – beaker Jul 06 '20 at 16:01
  • @beaker Well, no. as you can see from the picture at your link, the edge labels are the weight values: the length of the edges are entirley uncorrelated with the weights – Cla Jul 07 '20 at 14:59
  • Yeah, the edge length *proportional* to the weight rather than exact. – beaker Jul 07 '20 at 20:38
  • https://www.mathworks.com/help/examples/matlab/win64/GraphLayoutBasedOnEdgeWeightsExample_01.png Take the edges with 2 and 17 as labels. the have the same lenght. the edge with weight 6 is smaller than the one with edge 2 – Cla Jul 08 '20 at 08:58
  • 1
    That's the example of the default behavior of `plot` with a force layout. If you scroll down to the next bit of code where they modify it with `layout(p,'force','WeightEffect','direct')`, you'll see [this](https://www.mathworks.com/help/examples/matlab/win64/GraphLayoutBasedOnEdgeWeightsExample_02.png). – beaker Jul 08 '20 at 13:12
  • Ok, I feel super stupid now! thank a lot – Cla Jul 08 '20 at 14:54
  • 1
    No worries, I probably should have been more explicit about which code I was referring to. – beaker Jul 08 '20 at 15:10

0 Answers0