package intermediate
import (
"sort"
basegraph "github.com/d2lang/elk-go/internal/graph"
"github.com/d2lang/elk-go/internal/layered"
)
func ProcessSemiInteractiveCrossing (arena *layered .LGraphArena , graphID layered .LGraphID ) {
addedConstraints := false
for _ , layerID := range arena .Graph (graphID ).Layers {
positioned := make ([]layered .LNodeID , 0 )
for _ , nodeID := range arena .Layer (layerID ).Nodes {
node := arena .Node (nodeID )
if node .Type == layered .NormalNode && basegraph .Has (&node .Properties , layered .PositionOption ) {
positioned = append (positioned , nodeID )
}
}
sort .SliceStable (positioned , func (first , second int ) bool {
firstPosition := basegraph .Get (&arena .Node (positioned [first ]).Properties , layered .PositionOption )
secondPosition := basegraph .Get (&arena .Node (positioned [second ]).Properties , layered .PositionOption )
return firstPosition .Y < secondPosition .Y
})
for index := 1 ; index < len (positioned ); index ++ {
previous := positioned [index -1 ]
successors := basegraph .Get (&arena .Node (previous ).Properties , layered .InLayerSuccessorConstraints )
successors = append (successors , positioned [index ])
basegraph .Set (&arena .Node (previous ).Properties , layered .InLayerSuccessorConstraints , successors )
}
addedConstraints = addedConstraints || len (positioned ) > 0
}
if addedConstraints {
basegraph .Set (&arena .Graph (graphID ).Properties ,
layered .InLayerSuccessorConstraintsBetweenNonDummies , true )
}
}
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 .