// Copyright (c) 2010, 2020 Kiel University and others.
//
// 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 
	
)

// CalculateLayerSizesAndGraphHeight sets every layer's bounding size and the
// graph's vertical size and offset after node placement.
func ( *layered.LGraphArena,  layered.LGraphID) {
	 := .Graph()
	,  := math.Inf(1), math.Inf(-1)
	 := false
	for ,  := range .Layers {
		 := .Layer()
		.Size.X, .Size.Y = 0, 0
		if len(.Nodes) == 0 {
			continue
		}
		 = true
		for ,  := range .Nodes {
			 := .Node()
			.Size.X = math.Max(.Size.X, .Size.X+.Margin.Left+.Margin.Right)
		}
		 := .Node(.Nodes[0])
		 := .Position.Y - .Margin.Top
		if .Type == layered.ExternalPortNode {
			 -= basegraph.Get(&.Properties, layered.SpacingPortsSurrounding).Top
		}
		 := .Node(.Nodes[len(.Nodes)-1])
		 := .Position.Y + .Size.Y + .Margin.Bottom
		if .Type == layered.ExternalPortNode {
			 += basegraph.Get(&.Properties, layered.SpacingPortsSurrounding).Bottom
		}
		.Size.Y =  - 
		 = math.Min(, )
		 = math.Max(, )
	}
	if ! {
		,  = 0, 0
	}
	.Size.Y =  - 
	.Offset.Y -= 
}