package dagro

func runNormalize( *Graph) {
	 := asAttrs(.Graph())
	["dummyChains"] = []string{}
	for ,  := range .Edges() {
		normalizeEdge(, )
	}
}

func normalizeEdge( *Graph,  Edge) {
	,  := .V, .W
	,  := num(asAttrs(.Node()), "rank"), num(asAttrs(.Node()), "rank")
	 := asAttrs(.Edge())
	 := num(, "labelRank")
	if  == +1 {
		return
	}
	.RemoveEdge()
	for  := 0; +1 < ; ++ {
		++
		["points"] = []Point{}
		 := Attrs{
			"width": float64(0), "height": float64(0),
			"edgeLabel": , "edgeObj": , "rank": ,
		}
		 := addDummyNode(, "edge", , "_d")
		if  ==  {
			["width"], ["height"] = num(, "width"), num(, "height")
			["dummy"] = "edge-label"
			["labelpos"] = ["labelpos"]
		}
		setEdgePreservingName(, , , Attrs{"weight": num(, "weight")}, )
		if  == 0 {
			 := asAttrs(.Graph())["dummyChains"].([]string)
			asAttrs(.Graph())["dummyChains"] = append(, )
		}
		 = 
	}
	setEdgePreservingName(, , , Attrs{"weight": num(, "weight")}, )
}

func undoNormalize( *Graph) {
	,  := asAttrs(.Graph())["dummyChains"].([]string)
	for ,  := range  {
		 := 
		 := asAttrs(.Node())
		 := ["edgeLabel"].(Attrs)
		 := ["edgeObj"].(Edge)
		.SetEdgeObject(, )
		for stringValue(, "dummy") != "" {
			 := .Successors()[0]
			.RemoveNode()
			,  := ["points"].([]Point)
			["points"] = append(, Point{X: num(, "x"), Y: num(, "y")})
			if stringValue(, "dummy") == "edge-label" {
				["x"], ["y"] = num(, "x"), num(, "y")
				["width"], ["height"] = num(, "width"), num(, "height")
			}
			 = 
			 = asAttrs(.Node())
		}
	}
}