package dagroimport// longestPath initializes ranks by pushing every node as low as its outgoing// minlen constraints permit. This is a direct port of lib/rank/util.js.func longestPath( *Graph) { := make(map[string]bool, .NodeCount())varfunc(string) float64 = func( string) float64 { := asAttrs(.Node())if [] {returnnum(, "rank") } [] = true := math.Inf(1)for , := range .OutEdges() { := (.W) - num(asAttrs(.Edge()), "minlen")if < { = } }ifmath.IsInf(, 1) { = 0 } ["rank"] = return }for , := range .Sources() { () }}// slack is the difference between an edge's current length and minlen.func slack( *Graph, Edge) float64 { := num(asAttrs(.Node(.V)), "rank") := num(asAttrs(.Node(.W)), "rank")return - - num(asAttrs(.Edge()), "minlen")}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.