kompose/vendor/github.com/gonum/graph/concrete/util.go
Tomas Kral 1f8a0e06c9
Upgrade OpenShift and its dependencies.
OpenShift version 1.4.0-alpha.0
2016-10-18 12:04:00 +02:00

45 lines
805 B
Go

// Copyright ©2014 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package concrete
import (
"math"
"github.com/gonum/graph"
)
type nodeSorter []graph.Node
func (ns nodeSorter) Less(i, j int) bool {
return ns[i].ID() < ns[j].ID()
}
func (ns nodeSorter) Swap(i, j int) {
ns[i], ns[j] = ns[j], ns[i]
}
func (ns nodeSorter) Len() int {
return len(ns)
}
// The math package only provides explicitly sized max
// values. This ensures we get the max for the actual
// type int.
const maxInt int = int(^uint(0) >> 1)
var inf = math.Inf(1)
func isSame(a, b float64) bool {
return a == b || (math.IsNaN(a) && math.IsNaN(b))
}
func max(a, b int) int {
if a > b {
return a
} else {
return b
}
}