package intermediate
import (
basegraph "github.com/d2lang/elk-go/internal/graph"
"github.com/d2lang/elk-go/internal/layered"
)
func ProcessInLayerConstraints (arena *layered .LGraphArena , graphID layered .LGraphID ) {
for _ , layerID := range arena .Graph (graphID ).Layers {
original := append ([]layered .LNodeID (nil ), arena .Layer (layerID ).Nodes ...)
topInsertionIndex := -1
bottom := make ([]layered .LNodeID , 0 )
for index , nodeID := range original {
constraint := basegraph .Get (&arena .Node (nodeID ).Properties , layered .InternalInLayerConstraint )
if topInsertionIndex < 0 {
if constraint != layered .InLayerConstraintTop {
topInsertionIndex = index
}
} else if constraint == layered .InLayerConstraintTop {
arena .SetNodeLayer (nodeID , nil )
arena .SetNodeLayerAt (nodeID , &layerID , topInsertionIndex )
topInsertionIndex ++
}
if constraint == layered .InLayerConstraintBottom {
bottom = append (bottom , nodeID )
}
}
for _ , nodeID := range bottom {
arena .SetNodeLayer (nodeID , nil )
arena .SetNodeLayer (nodeID , &layerID )
}
}
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .