package placementcost

import (
	

	
	
)

// AxisScore measures how strongly nodes share one visual axis.
func ( layoutgraph.Nodes) float64 {
	if len() < 2 {
		return 1
	}
	if len() == 2 {
		if [0].Orientation([1]).IsDiagonal() {
			return 0
		}
		return 1
	}

	 := math.Inf(-1)
	var  *layoutgraph.Node
	 := math.Inf(-1)
	var  *layoutgraph.Node
	for ,  := range  {
		if .Width >  {
			 = .Width
			 = 
		}
		if .Height >  {
			 = .Height
			 = 
		}
	}

	 := true
	for ,  := range  {
		if  ==  {
			continue
		}
		if !.Orientation().IsHorizontal() {
			 = false
			break
		}
	}
	if  {
		 := .Center()
		 := 0.0
		for ,  := range  {
			if  ==  {
				continue
			}
			 := 0.0
			for ,  := range []float64{0.25, 0.5, 0.75} {
				 := .TopLeft.Y + *.Height
				if .OverlapsLine(geo.NewPoint(.X, ), geo.NewPoint(.Center().X, ), 0) {
					 += 0.33
				}
			}
			if .Height < 0.25*.Height {
				 *= 3
			} else if .Height < 0.75*.Height {
				 *= 2
			}
			if  == 0.99 {
				++
			} else {
				 += 
			}
		}
		return math.Max(0.33, /float64(len()-1))
	}

	 := true
	for ,  := range  {
		if  ==  {
			continue
		}
		if !.Orientation().IsVertical() {
			 = false
			break
		}
	}
	if  {
		 := .Center()
		 := 0.0
		for ,  := range  {
			if  ==  {
				continue
			}
			 := 0.0
			for ,  := range []float64{0.25, 0.5, 0.75} {
				 := .TopLeft.X + *.Width
				if .OverlapsLine(geo.NewPoint(, .Y), geo.NewPoint(, .Center().Y), 0) {
					 += 0.33
				}
			}
			if .Width < 0.25*.Width {
				 *= 3
			} else if .Width < 0.75*.Width {
				 *= 2
			}
			if  == 0.99 {
				++
			} else {
				 += 
			}
		}
		return math.Max(0.33, /float64(len()-1))
	}
	return 0
}