How to convert 2-way edges in digraphs to straight single line edges?

3 views (last 30 days)
In small network, two-way looping links are easy to understand (left in the figure), but in bigger networks, two-way loops make the network really unpleasant (right in the figure). Is there any way I can draw the two directional digraphs with straight lines? (with maybe the directions shown by arrows on the links (just like it is shown in one-directional digraphs) but in two directions.
I posted this question before but got no answers.. hoping for some this time... Thanks

Accepted Answer

Achter
Achter on 7 Aug 2016
Well.. there is no direct way with which MATLAB can convert the circular two-way links to a single straight line. But deleting the backward link from each OD pair and plotting the graph as simple graph will do the trick.. for that I used this code: ----->
input1 = xlsread('neu.xlsx');
input2 = xlsread('neu_xy.xlsx');
x = input2(:,2)';
y = input2(:,3)';
a = input1(:,[1 2])';
j=0;
count = 0;
while j < size(a,2);
j = j+1;
for i = 1:size(a,2)-1
if flipud(a(:,i)) == a(:,j)
a(:,j) =[];
count = count + 1;
end
end
end
G = graph(a(1,:),a(2,:));
h = plot(G,'XData',x,'YData',y);
highlight (h,1:16, 'NodeColor','k','MarkerSize',6);
  1 Comment
Bezalem Eshetu Yirdaw
Bezalem Eshetu Yirdaw on 6 Oct 2022
My apologies am not here to answer your question, rather, could you provide me the code to use different colors for the edges please. Thanks.

Sign in to comment.

More Answers (0)

Categories

Find more on Networks 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!