...

Source file src/k8s.io/kubernetes/third_party/forked/gonum/graph/simple/simple.go

Documentation: k8s.io/kubernetes/third_party/forked/gonum/graph/simple

     1  // Copyright ©2014 The gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package simple provides a suite of simple graph implementations satisfying
     6  // the gonum/graph interfaces.
     7  package simple
     8  
     9  import (
    10  	"math"
    11  
    12  	"k8s.io/kubernetes/third_party/forked/gonum/graph"
    13  )
    14  
    15  // Node is a simple graph node.
    16  type Node int
    17  
    18  // ID returns the ID number of the node.
    19  func (n Node) ID() int {
    20  	return int(n)
    21  }
    22  
    23  // Edge is a simple graph edge.
    24  type Edge struct {
    25  	F, T graph.Node
    26  	W    float64
    27  }
    28  
    29  // From returns the from-node of the edge.
    30  func (e Edge) From() graph.Node { return e.F }
    31  
    32  // To returns the to-node of the edge.
    33  func (e Edge) To() graph.Node { return e.T }
    34  
    35  // Weight returns the weight of the edge.
    36  func (e Edge) Weight() float64 { return e.W }
    37  
    38  // maxInt is the maximum value of the machine-dependent int type.
    39  const maxInt int = int(^uint(0) >> 1)
    40  
    41  // isSame returns whether two float64 values are the same where NaN values
    42  // are equalable.
    43  func isSame(a, b float64) bool {
    44  	return a == b || (math.IsNaN(a) && math.IsNaN(b))
    45  }
    46  

View as plain text