Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The nodes of tree are overlap when plot a tree. Maybe a bug when plot compex trees. #186

Closed
2 tasks done
yizhichun opened this issue Aug 9, 2018 · 6 comments
Closed
2 tasks done

Comments

@yizhichun
Copy link

yizhichun commented Aug 9, 2018

  • This issue is for the Python interface of igraph.
  • This issue is a bug report or a feature request, not a support question.

igraph_bug2

The nodes of tree are overlap when plot a complex tree, as shown in attached figure.
May be has a bug.
My tree structure as following:

edges = 
[(0, 1), (1, 2), (2, 3), (3, 4), (3, 5), (2, 6), (6, 7), (6, 8), (8, 9), (9, 10), (8, 11), (11, 12), (8, 13), (6, 14), (14, 15), (14, 16), (14, 17), (14, 18), (1, 19), (19, 20), (20, 21), (20, 22), (22, 23), (22, 24), (22, 25), (20, 26), (26, 27), (27, 28), (27, 29), (27, 30), (26, 31), (26, 32), (32, 33), (32, 34), (26, 35), (35, 36), (35, 37), (1, 38), (38, 39), (38, 40), (38, 41), (41, 42), (41, 43), (1, 44), (44, 45), (45, 46), (45, 47), (47, 48), (48, 49), (47, 50), (50, 51), (47, 52), (52, 53), (44, 54), (54, 55), (54, 56), (56, 57), (57, 58), (58, 59), (58, 60), (57, 61), (56, 62), (56, 63), (63, 64), (44, 65), (65, 66), (66, 67), (66, 68), (68, 69), (65, 70), (65, 71), (71, 72), (72, 73), (65, 74), (65, 75), (75, 76), (75, 77)]

The plot codes as following:

from igraph import *
tree = Graph(edges = edges)
plot(tree,layout = tree.layout_reingold_tilford(root=[0]))

How to fix this, thank you!

@ntamas
Copy link
Member

ntamas commented Aug 16, 2018

Yes, this is a bug in the underlying implementation of the Reingold-Tilford algorithm in the C core of igraph. I don't have too much spare time to deal with this, so if you would like to help, can you please try to construct a minimal example that still exhibits the problem, e.g., by removing leaf nodes one by one from the tree until the issue does not appear any more? This would be a great help to me so I could start exploring with the smallest example that is possible to be derived from the current one.

@yizhichun
Copy link
Author

I am glad to help. This will be much helpful for plot-ing complex trees.

After testing a lot, I have found a typical example that exhibits the problem. As following:

from igraph import *
edges = [(0, 1),
 (1, 2),
 (2, 3),
 (2, 4),
 (2, 5),
 (2, 6),
 (0, 7),
 (7, 8),
 (7, 9),
 (7, 10),
 (10, 11),
 (10, 12),
 (10, 13),
 (10, 14)]
tree = Graph(edges=edges)
tree.vs['label'] = [v.index for v in tree.vs]
plot(tree,layout=tree.layout('rt',root=[0]),bbox=(300,300))

screen shot 2018-08-21 at 3 05 21 pm

The keys of this example are like this: the nodes in Level 4 will be out of the drawing limitation, when there are two nodes, 8 and 9, on the left of 10, in the Level 3.

If the four nodes in Level 4 are children of node 9, which means just one node 8 on the left of 9, the trees drawing well.
screen shot 2018-08-21 at 3 19 53 pm

If there are two node on the right of left root in Level 3, the trees are also drawing well.
screen shot 2018-08-21 at 3 22 10 pm

If the leaves are in Level 3, the trees are also drawing well.
screen shot 2018-08-21 at 3 25 26 pm

If the leaves are in Level 4 or higher, this bug will be appear.
screen shot 2018-08-21 at 3 19 19 pm

I hope this would be helpful. I'm pleasure to do whatever else I can do to fix it.
Thanks.

@yizhichun
Copy link
Author

Another example is like this:

from igraph import *
edges = [(0, 1),
 (1, 2),
 (2, 3),
 (0, 4),
 (4, 5),
 (4, 6),
 (0, 7),
 (7, 8),
 (8, 9),
 (8, 10),
 (8, 11),
 (8, 12),
 (8, 13),
 (8, 14),
 (8, 15),
 (8, 16)]
tree = Graph(edges=edges)
tree.vs['label'] = [v.index for v in tree.vs]
plot(tree,layout=tree.layout('rt',root=[0]),bbox=(300,300))

screen shot 2018-08-21 at 4 19 18 pm

@doRemy
Copy link

doRemy commented Oct 21, 2019

Thank you for your help to understand this issue.

Without modifying the edges list, how would you go about finding a solution to this problem?

Is there a layout option to prevent these kind of overlapping nodes?

@szhorvat
Copy link
Member

Likely the same as igraph/igraph#879

@ntamas
Copy link
Member

ntamas commented Jan 30, 2020

Yes, it's the same issue. Let's continue the discussion there as it has to be fixed in the C layer.

@ntamas ntamas closed this as completed Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants