// Copyright (c) 2010, 2015 Kiel University and others.
// Copyright (c) 2026 The elk-go Authors.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0.
//
// SPDX-License-Identifier: EPL-2.0

package intermediate

import (
	basegraph 
	
)

// ProcessInLayerConstraints moves TOP nodes before ordinary nodes and BOTTOM
// nodes to the end while preserving the encounter order within each group.
func ( *layered.LGraphArena,  layered.LGraphID) {
	for ,  := range .Graph().Layers {
		 := append([]layered.LNodeID(nil), .Layer().Nodes...)
		 := -1
		 := make([]layered.LNodeID, 0)
		for ,  := range  {
			 := basegraph.Get(&.Node().Properties, layered.InternalInLayerConstraint)
			if  < 0 {
				if  != layered.InLayerConstraintTop {
					 = 
				}
			} else if  == layered.InLayerConstraintTop {
				.SetNodeLayer(, nil)
				.SetNodeLayerAt(, &, )
				++
			}
			if  == layered.InLayerConstraintBottom {
				 = append(, )
			}
		}
		for ,  := range  {
			.SetNodeLayer(, nil)
			.SetNodeLayer(, &)
		}
	}
}