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

Determine height of nodes from number of ancestors #96

Closed
hingehe opened this issue May 21, 2019 · 8 comments
Closed

Determine height of nodes from number of ancestors #96

hingehe opened this issue May 21, 2019 · 8 comments
Labels
question Further information is requested

Comments

@hingehe
Copy link

hingehe commented May 21, 2019

This is exactly what I needed for the development of my project. Thanks for that! Except one little thing:
I'd like to have all "leafs" of the tree with the same (lowest) height. If you consider the following edges:
A->B
B->C

You get a straight line from A over B to C, which is fine. But if you then add
A->D

The node D (also a leaf without any descendants) is not on the bottom line beneath C, but it is in the second line beneath B. It would be easy to implement, just by calculating a "row-score" (number of descendants) for each node. This score then determines the vertical position of each node. All leaves with score = 0 are on the bottom line, their direct acenstors are placed above (higher as) them with score = 1 and so on.

@magjac
Copy link
Owner

magjac commented May 21, 2019

Thank you for the kind words and your interest in the Graphviz Visual Editor.

Apologies if I misunderstand you proposal.

From the online Help -> About:

The Graphviz Visual Editor is a web application for interactive visual editing of Graphviz graphs described in the DOT language. It is not a general drawing application. It can only generate graphs that are possible to describe with DOT.

The Graphviz Visual Editor does not have any layout algorithms other than provided by Graphviz or the DOT language and therefore it is not possible to affect the layout by changing the implementation of the Graphviz Visual Editor.

That said, one way of achieving what you want is to place the nodes in question in a subgraph and use the rank attribute:

digraph {
    A -> B
    B -> C
    A -> D
    {rank=same C D}
}

Try it live at http://magjac.com/graphviz-visual-editor/?dot=digraph%20%7B%0A%20%20%20%20A%20-%3E%20B%0A%20%20%20%20B%20-%3E%20C%0A%20%20%20%20A%20-%3E%20D%0A%20%20%20%20%7Brank%3Dsame%20C%20D%7D%0A%7D

Please let me know if you have further questions.

@magjac magjac added the question Further information is requested label May 21, 2019
@hingehe
Copy link
Author

hingehe commented May 22, 2019

Thanks for your quick reply! I do already use the rank=same feature. But it does not completely do what I want. Please consider this graph:

GRAPH

The number behind the Nodes-Name means their direct and indirect descendants. Their "Score". I want all nodes with the same score in one 'row' of the graph. As you can see: Node E (2) is on the same row as B and D (both 1). Where I'd rather have it standalone on a row above B and D and one below A. Maybe is there a dirty-trick with a hidden node of score 2?

Is there a solution for that too? If not: Never mind. I love this tool either way! It helped me so much with my developement and bugtracking of my code! Wow!

@magjac
Copy link
Owner

magjac commented May 22, 2019

You can add extra invisible edges like in this graph.

@magjac
Copy link
Owner

magjac commented May 22, 2019

Or without rank completely like in this graph.

@magjac
Copy link
Owner

magjac commented May 22, 2019

Be aware of the bug I just found in the Export as URL function: #97.

@hingehe
Copy link
Author

hingehe commented May 23, 2019

Hi magjac
Cool, now I can "fake" it with the hidden edges. Thanks for that! Unfortunately, it is quite hard for me, to find the right hidden edges out of my underlying dataset.

But now you know exactly, what I meant with my initial question. I would appriciate a "button" somewhere in the settings, which says "Rank the vertices Hingehe-Style" (or something more meaningful). It is easy to implement, because the number of descendants determines the rank in the graph. Maybe it is worth a new feature-request. But that is up to you! You've helped me more than I thought! Thanks for that! I am farest from being a front-end-developer (what is it? VueJS?), so I cannot code it myself, sorry!

@magjac
Copy link
Owner

magjac commented May 23, 2019

I did understand completely what you wanted, but as I tried to explain above, the Graphviz Visual Editor could never influence the layout in any way. The layout is 100% determined by the DOT source code and the chosen layout engine, which is not implemented in the Graphviz Visual Editor, but in Graphviz itself. If you want to change how the layout engine works (including additions or modifications to the DOT language), you must file an issue at https://gitlab.com/graphviz/graphviz/.

@magjac
Copy link
Owner

magjac commented May 23, 2019

On second thought, if what you want is a "button" that modifies the users DOT source code by adding invisible edges I guess it could in principle be done in special cases likes yours, but in the general case it wouldn't. Think of graphs with loops for instance.

@magjac magjac added this to Not yet planned to do in Graphviz Visual Editor short-term activities May 31, 2019
@magjac magjac closed this as completed Jun 22, 2019
Graphviz Visual Editor short-term activities automation moved this from Not yet planned to do to Done and merged but not yet released Jun 22, 2019
@magjac magjac removed this from Done and merged but not yet released in Graphviz Visual Editor short-term activities Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants