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

Prettier Faster Sorting for Large Trees #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

microuser
Copy link

For graphs with text labelled segments, having the arrows flow from left to right makes more readable. The random() function was replaced with a random near diagonal. This assumes that the data node parents are created before node children. This also tends to create a more stable and quicker sort.

For graphs with text labelled segments, having the arrows flow from left to right makes more readable. The random() function was replaced with a random near diagonal. This assumes that the data node parrents are created before node children. This also tends to create a more stable and quicker sort.
@@ -338,7 +339,7 @@
Layout.ForceDirected.prototype.point = function(node) {
if (!(node.id in this.nodePoints)) {
var mass = (node.data.mass !== undefined) ? node.data.mass : 1.0;
this.nodePoints[node.id] = new Layout.ForceDirected.Point(Vector.random(), mass);
this.nodePoints[node.id] = new Layout.ForceDirected.Point(Vector.randomlyDiagonal(), mass);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more math during creation, saves lots of iterations of force directed sorting/spacing.

@tdhsmith
Copy link
Contributor

I worry that tailoring the random function for certain graphs types might damage other uses. For example, graphs with cycles aren't going to benefit because by necessity they will have arrows in both directions. So I'd personally prefer this setting to be optional rather than the default setup.

Also won't most branch-heavy trees still find equilibrium with the root in the center and the leaves spread out in all directions, regardless of how they are initially arranged? (Perhaps you could do something interesting by applying a force that tries to orient all edges down and towards the right, though I'm not sure it would be easy to balance with the other forces...)

@tdhsmith
Copy link
Contributor

Doesn't address the sorting speed, but I just committed an option in springyui.js to flip edge labels when they are upside-down.

EDIT: See my commit note - I guess this is reverting something recently changed. Whoops.

@dhotson
Copy link
Owner

dhotson commented Feb 26, 2014

Hey sorry, just to clarify—the aim of this is to arrange nodes roughly from left to right?

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

Successfully merging this pull request may close these issues.

3 participants