How to avoid overlapping edges in a bi directed graph with biograph?

조회 수: 15 (최근 30일)
JQ
JQ 2015년 4월 8일
댓글: Niranjana K 2019년 3월 22일
I'm using Matlab Bioinformatics Toolbox to draw a bidirected network graph with some nodes and some edges. Eg.: there is a link from node 1 to node 2 and there is a link from node 2 to node 1 with different weights. I want to specify my own coordinates to locate the nodes.
I tried in several ways but the problem is that I'm getting overlapped edges between the nodes. The toolbox initially sets the coordinates in a way the the graph is well drawn. But if a user wants to change the "Position" property of each node, then the resulting graph has overlapped edges.
Here is a simple code that produces overlapped links:
A = [0 20; 23 0]
bg=biograph(A, {'1' '2'},'Scale',1, 'LayoutScale', 1, 'ShowWeights','on')
h=view(bg)
set(h.Nodes(1),'Position',[10, 40])
set(h.Nodes(2),'Position',[70, 40])
dolayout(h, 'PathsOnly', true);
Is it a bug? How can I choose the location of the nodes without getting overlapped edges?
  댓글 수: 1
Niranjana K
Niranjana K 2019년 3월 22일
Yes you can probably do this and in the menubar only you have the option like refresh you can use to overcome overlapping. Thankyou

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

답변 (2개)

Paola Favaretto
Paola Favaretto 2015년 4월 9일
Hello,
Currently the algorithm used by dolayout to draw the edges with option 'PathsOnly' set to true works in a way that any two edges like the ones in your example collapse into a single bidirectional edge. The weights are correctly reported on the edges.
Unfortunately at the moment there is no easy workaround to get to the layout that you are envisioning. You could try to position the nodes in a way that prevents the edges from becoming one bidirectional edge: for example, you can position the nodes slightly off on the y axis, instead of aligning them.
-Paola

JQ
JQ 2015년 9월 7일
Thank you very much Paola for your kind answer. I'm very very sorry for my late answer. It's a pity that no workarounds exist at the moment. It should be not so difficult to implement a solution. The possibility to customize the graph would be very helpful. I hope that there will be some solutions very soon.

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by