// 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 p4nodes

import (
	basegraph 
	
)

// SimpleNodePlacer stacks each layer and centers it around the tallest layer.
type SimpleNodePlacer struct{}

func (*SimpleNodePlacer) (
	 *layered.LGraphArena,
	 layered.LGraphID,
) layered.ProcessorConfiguration {
	var  layered.ProcessorConfiguration
	if basegraph.Get(&.Graph().Properties, layered.GraphProperties)&layered.GraphPropertyExternalPorts != 0 {
		.AddBefore(layered.PhaseEdgeRouting, layered.HierarchicalPortPositionProcessor)
	}
	return 
}

func (*SimpleNodePlacer) ( *layered.LGraphArena,  layered.LGraphID) error {
	 := 0.0
	for ,  := range .Graph().Layers {
		 := .Layer()
		.Size.Y = 0
		var  *layered.LNodeID
		for ,  := range .Nodes {
			 := .Node()
			if  != nil {
				.Size.Y += layered.VerticalSpacing(, , *)
			}
			.Size.Y += .Margin.Top + .Size.Y + .Margin.Bottom
			 := 
			 = &
		}
		if .Size.Y >  {
			 = .Size.Y
		}
	}
	for ,  := range .Graph().Layers {
		 := .Layer()
		 := ( - .Size.Y) / 2
		var  *layered.LNodeID
		for ,  := range .Nodes {
			 := .Node()
			if  != nil {
				 += layered.VerticalSpacing(, , *)
			}
			 += .Margin.Top
			.Position.Y = 
			 += .Size.Y + .Margin.Bottom
			 := 
			 = &
		}
	}
	return nil
}