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

3 views (last 30 days)
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 Comment
Niranjana K
Niranjana K on 22 Mar 2019
Yes you can probably do this and in the menubar only you have the option like refresh you can use to overcome overlapping. Thankyou

Sign in to comment.

Answers (2)

Paola Favaretto
Paola Favaretto on 9 Apr 2015
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 on 7 Sep 2015
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.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!