an operator that assigns coordinates to layered SugiNodes
This function must assign each node an x coordinate, and return the width
of the layout. The x coordinates should satisfy the
SugiSeparation, and all be between zero and the returned width.
Example
In order to illustrate what it might look like, below we demonstrate a
coordinate operator that assigns an x attached to the nodes themselves. If
the node is a dummy node (e.g. a point on an edge between two nodes), then
instead we average the coordinate. Note that this isn't compliant since it
might not respect sep, and is therefore only an illustration.
customCoord<Nextends { x: number }, L>(layers: SugiNode<N, L>[][], sep: SugiSeparation<N, L>): number { // determine span of xs letmin = Infinity; letmax = -Infinity; for (constlayeroflayers) { for (constnodeoflayer) { const { data } = node; constx = node.x = data.role === "node" ? data.node.data.x : (data.link.source.data.x + data.link.target.data.x) / 2; min = Math.min(min, x - sep(undefined, node)); max = Math.max(max, x + sep(node, undefined)); } } // assign xs for (constnodeofdag) { node.x = -= min; } returnmax - min; }
an operator that assigns coordinates to layered SugiNodes
This function must assign each node an
x
coordinate, and return the width of the layout. Thex
coordinates should satisfy the SugiSeparation, and all be between zero and the returned width.Example
In order to illustrate what it might look like, below we demonstrate a coordinate operator that assigns an x attached to the nodes themselves. If the node is a dummy node (e.g. a point on an edge between two nodes), then instead we average the coordinate. Note that this isn't compliant since it might not respect
sep
, and is therefore only an illustration.