package layoutgraph

import (
	

	
)

// These limits are exported for sibling graph codecs. They are part of the
// engine's resource-safety contract, not configurable layout policy.
const (
	MaxSerializationTopologyReferences = maxEngineTopologyReferences
	MaxSerializationRoutePoints        = maxEngineRoutePoints
	MaxSerializationPreflightWork      = maxEnginePreflightWork
)

// ValidateForSerialization performs the layout graph's complete bounded
// topology preflight before graphjson starts encoding references.
func ( context.Context,  *Graph) error {
	return validateEngineGraph(, "SerializeGraph", )
}

// ContainerOrderForSerialization returns the stable reverse-DFS fixture
// order while charging the caller's shared serialization work budget.
func ( *Graph,  *limits.WorkGuard) ([]*Node, error) {
	return .containerRDFSOrderContext(nil, )
}

// NodeIDForSerialization represents a nil root with the fixture ID zero.
func ( *Node) EntityID {
	return .entityID()
}

func ( *Node) []*Node {
	return .orderedNears()
}

func ( *Graph) (, ,  float64) {
	.costMu.RLock()
	defer .costMu.RUnlock()
	return .crossingCost, .turnCost, .nonCenterPortCost
}

func ( *Node,  *Edge) {
	.addEdge()
}

func ( *Node) {
	.isContainer = true
}

func ( *Node) {
	.isClusterVessel = true
}

func ( *Cluster) bool {
	return .isActive()
}

func ( *Sequence) bool {
	return .isActive()
}

func ( map[*Node]int) *Hierarchy {
	return &Hierarchy{level: }
}

func ( *Hierarchy) map[*Node]int {
	return .level
}

// BuildNodeToTreeForDeserialization derives the auxiliary tree index under
// the decoder's shared work budget.
func ( map[*Node][]*Tree,  *limits.WorkGuard) (map[*Node]*Tree, error) {
	 := &Graph{Trees: }
	if  := .buildNodeToTreeGuarded();  != nil {
		return nil, 
	}
	return .NodeToTree, nil
}

// PublishDeserializedGraph atomically replaces graph-owned state while
// retaining the destination graph's mutex identity.
func (,  *Graph, , ,  float64) {
	.IsRootHierarchy = .IsRootHierarchy
	.Nodes = .Nodes
	.Edges = .Edges
	.CellSize = .CellSize

	.costMu.Lock()
	.crossingCost = 
	.turnCost = 
	.nonCenterPortCost = 
	.edgeLengthCache = make(map[uint64]float64)
	.costMu.Unlock()

	.Containers = .Containers
	.Clusters = .Clusters
	.Trees = .Trees
	.NodeToTree = .NodeToTree
	.Hubs = .Hubs
	.Sequences = .Sequences
	.Directions = .Directions
	.CommonUncleSiblings = .CommonUncleSiblings
}