Package org.onlab.graph
Class ScalarWeight
- java.lang.Object
-
- org.onlab.graph.ScalarWeight
-
-
Field Summary
Fields Modifier and Type Field Description static ScalarWeightNON_VIABLE_WEIGHTInstance of scalar weight to mark links/paths which can not be traversed.
-
Constructor Summary
Constructors Constructor Description ScalarWeight(double value)Creates a new scalar weight with the given double value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Weight otherWeight)booleanequals(java.lang.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.java.lang.StringtoString()static ScalarWeighttoWeight(double value)Creates a new scalar weight with the given double value.doublevalue()Returns inner double value.
-
-
-
Field Detail
-
NON_VIABLE_WEIGHT
public static final ScalarWeight NON_VIABLE_WEIGHT
Instance of scalar weight to mark links/paths which can not be traversed.
-
-
Method Detail
-
toWeight
public static ScalarWeight toWeight(double value)
Creates a new scalar weight with the given double value.- Parameters:
value- double value- Returns:
- scalar weight instance
-
merge
public Weight merge(Weight otherWeight)
Description copied from interface:WeightMerges the given weight with this one returning a new aggregated weight.
-
subtract
public Weight subtract(Weight otherWeight)
Description copied from interface:WeightSubtracts the given weight from this one and produces a new weight.
-
isViable
public boolean isViable()
Description copied from interface:WeightReturns true if the weighted subject (link/path) can be traversed; false otherwise.
-
compareTo
public int compareTo(Weight otherWeight)
- Specified by:
compareToin interfacejava.lang.Comparable<Weight>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isNegative
public 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 interfaceWeight- Returns:
- true if the weight is negative, false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
value
public double value()
Returns inner double value.- Returns:
- double value
-
setSamenessThreshold
public static void setSamenessThreshold(double threshold)
Sets a new sameness threshold for comparing cost values; default is isDouble.MIN_VALUE.- Parameters:
threshold- fractional double value
-
samenessThreshold
public static double samenessThreshold()
Returns the current sameness threshold for comparing cost values.- Returns:
- current threshold
-
-