Package org.onlab.graph
Class ScalarWeight
- java.lang.Object
-
- org.onlab.graph.ScalarWeight
-
-
Field Summary
Fields Modifier and Type Field Description static ScalarWeight
NON_VIABLE_WEIGHT
Instance 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 int
compareTo(Weight otherWeight)
boolean
equals(java.lang.Object obj)
int
hashCode()
boolean
isNegative()
Returns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).boolean
isViable()
Returns true if the weighted subject (link/path) can be traversed; false otherwise.Weight
merge(Weight otherWeight)
Merges the given weight with this one returning a new aggregated weight.static double
samenessThreshold()
Returns the current sameness threshold for comparing cost values.static void
setSamenessThreshold(double threshold)
Sets a new sameness threshold for comparing cost values; default is isDouble.MIN_VALUE
.Weight
subtract(Weight otherWeight)
Subtracts the given weight from this one and produces a new weight.java.lang.String
toString()
static ScalarWeight
toWeight(double value)
Creates a new scalar weight with the given double value.double
value()
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:Weight
Merges the given weight with this one returning a new aggregated weight.
-
subtract
public Weight subtract(Weight otherWeight)
Description copied from interface:Weight
Subtracts the given weight from this one and produces a new weight.
-
isViable
public boolean isViable()
Description copied from interface:Weight
Returns true if the weighted subject (link/path) can be traversed; false otherwise.
-
compareTo
public int compareTo(Weight otherWeight)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Weight>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isNegative
public boolean isNegative()
Description copied from interface:Weight
Returns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).- Specified by:
isNegative
in interfaceWeight
- Returns:
- true if the weight is negative, false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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
-
-