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

[Question] Mrtree center node with multiple parents #297

Open
fima-methodic opened this issue Aug 28, 2024 · 7 comments
Open

[Question] Mrtree center node with multiple parents #297

fima-methodic opened this issue Aug 28, 2024 · 7 comments
Labels

Comments

@fima-methodic
Copy link

Hey, i am using elkjs and i am trying to achieve a result where when a node in the tree has 2 parents (and 2 edges) it will be centered beneath them and not aligned to the left.

Here is a screenshot of the current behavior:
Screenshot 2024-08-28 at 15 12 17
link to elklive

I need the bottom node to be aligned to the center - how can i achieve that?

I'll be glad to provide more information if needed

@soerendomroes
Copy link
Member

mrtree also "works" for graphs that are not trees, as the one you used. However, it handles all edges that are not part of the primary tree differently and does not consider them for node placement. Hence, this algorithm cannot do what you want it to do.

Maybe the layered algorithm works for you.

@fima-methodic
Copy link
Author

@soerendomroes The layered algorithm works for me pretty well beside 1 issue that i have with sorting some of the nodes.
Extending your example the child nodes n2 - a, n3 - b, n4 - c being placed like this (from left to right) -> n4 - n2 - n3.
Is there a way to sort the nodes in a different way (n2 - n3 - n4)?

@soerendomroes
Copy link
Member

Have you tried setting considerModelOrder.strategy to NODES_AND_EDGES?

@fima-methodic
Copy link
Author

Thank you very much for your help @soerendomroes it worked :)

@Avonavi232
Copy link

@soerendomroes Hey there!
I was looking for a solution for the similar question and came here. I hope you could have some time to help 🙏

What I'd want to achieve is placing the node which has 1+ parents under the certain parent, which edge is "more important" or "heavier".

image

Is it possible?)

@soerendomroes
Copy link
Member

@Avonavi232
Copy link

@soerendomroes yeah, it works, thx!

here's how I used this prop. Seems to be working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants