-
Notifications
You must be signed in to change notification settings - Fork 630
Description
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.
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!