Package org.onlab.graph
Class ScalarWeight
- java.lang.Object
- 
- org.onlab.graph.ScalarWeight
 
- 
- All Implemented Interfaces:
- Comparable<Weight>,- Weight
 
 public class ScalarWeight extends Object implements Weight Weight implementation based on a double value.
- 
- 
Field SummaryFields Modifier and Type Field Description static ScalarWeightNON_VIABLE_WEIGHTInstance of scalar weight to mark links/paths which can not be traversed.
 - 
Constructor SummaryConstructors Constructor Description ScalarWeight(double value)Creates a new scalar weight with the given double value.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Weight otherWeight)booleanequals(Object obj)inthashCode()booleanisNegative()Returns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).booleanisViable()Returns true if the weighted subject (link/path) can be traversed; false otherwise.Weightmerge(Weight otherWeight)Merges the given weight with this one returning a new aggregated weight.static doublesamenessThreshold()Returns the current sameness threshold for comparing cost values.static voidsetSamenessThreshold(double threshold)Sets a new sameness threshold for comparing cost values; default is isDouble.MIN_VALUE.Weightsubtract(Weight otherWeight)Subtracts the given weight from this one and produces a new weight.StringtoString()static ScalarWeighttoWeight(double value)Creates a new scalar weight with the given double value.doublevalue()Returns inner double value.
 
- 
- 
- 
Field Detail- 
NON_VIABLE_WEIGHTpublic static final ScalarWeight NON_VIABLE_WEIGHT Instance of scalar weight to mark links/paths which can not be traversed.
 
- 
 - 
Method Detail- 
toWeightpublic static ScalarWeight toWeight(double value) Creates a new scalar weight with the given double value.- Parameters:
- value- double value
- Returns:
- scalar weight instance
 
 - 
mergepublic Weight merge(Weight otherWeight) Description copied from interface:WeightMerges the given weight with this one returning a new aggregated weight.
 - 
subtractpublic Weight subtract(Weight otherWeight) Description copied from interface:WeightSubtracts the given weight from this one and produces a new weight.
 - 
isViablepublic boolean isViable() Description copied from interface:WeightReturns true if the weighted subject (link/path) can be traversed; false otherwise.
 - 
compareTopublic int compareTo(Weight otherWeight) - Specified by:
- compareToin interface- Comparable<Weight>
 
 - 
isNegativepublic boolean isNegative() Description copied from interface:WeightReturns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).- Specified by:
- isNegativein interface- Weight
- Returns:
- true if the weight is negative, false otherwise
 
 - 
valuepublic double value() Returns inner double value.- Returns:
- double value
 
 - 
setSamenessThresholdpublic static void setSamenessThreshold(double threshold) Sets a new sameness threshold for comparing cost values; default is isDouble.MIN_VALUE.- Parameters:
- threshold- fractional double value
 
 - 
samenessThresholdpublic static double samenessThreshold() Returns the current sameness threshold for comparing cost values.- Returns:
- current threshold
 
 
- 
 
-