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

Edge weights have no visible effect on layout #468

Open
megaboich opened this issue Jan 9, 2025 · 0 comments
Open

Edge weights have no visible effect on layout #468

megaboich opened this issue Jan 9, 2025 · 0 comments

Comments

@megaboich
Copy link

Hey, maybe this is a silly question, but I’m trying to add weights to my edges in DagreJS according to the wiki documentation, which states:

“The weight to assign edges. Higher weight edges are generally made shorter and straighter than lower weight edges.”

However, I don’t see any effect on the layout. I have multiple parallel threads with different weights, but changing these values doesn’t affect their relative order or geometry in any noticeable way.

Example
I have a small demo here on JSFiddle. The graph has five parallel “threads” going from a single “start” node to an “end” node, each with different weight values for the edges.

Screenshot 2025-01-09 at 10 48 11

This is code for defining edges:

// Thread 1
g.setEdge("Start", "A1", { weight: 2 })
g.setEdge("A1", "B1", { weight: 2 })
g.setEdge("B1", "End", { weight: 2 })

// Thread 2
g.setEdge("Start", "A2", { weight: 5 })
g.setEdge("A2", "B2", { weight: 5 })
g.setEdge("B2", "End", { weight: 5 })

// Thread 3
g.setEdge("Start", "A3", { weight: 10 })
g.setEdge("A3", "B3", { weight: 10 })
g.setEdge("B3", "End", { weight: 10 })

// Thread 4
g.setEdge("Start", "A4", { weight: 100 })
g.setEdge("A4", "B4", { weight: 100 })
g.setEdge("B4", "End", { weight: 100 })

// Thread 4
g.setEdge("Start", "A5", { weight: 1000 })
g.setEdge("A5", "B5", { weight: 1000 })
g.setEdge("B5", "End", { weight: 1000 })

My expectation is that the “heaviest” route (A5) might be placed in the center or otherwise distinguished from lighter routes, but this isn’t happening.

Question

  • Are edge weights currently expected to influence layout ordering or path shape in DagreJS?
  • Is there something else I need to configure (e.g., rankdir, ranker, acyclicity, or special layout options) for weights to have an effect?
  • Is this feature deprecated or only partially supported in the current version of Dagre?

Additional Context

  • Dagre version: (1.1.4)

Any guidance would be greatly appreciated!

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

1 participant