Interface LabelSemiring
-
public interface LabelSemiring
A semiring used to compose labels.When composing two labelled graphs, we need a way to combine labels along a path, and a way to combine labels from different paths connecting two nodes. These two operations are implemented by
multiply(Label, Label)
andadd(Label, Label)
. The name of the two methods are due to the fact that their operations must define a semiring for which you must also provide azero()
and aone()
. For instance, if a graph is labelled with weights, a semiring implementingmultiply(Label, Label)
by a standard sum andadd(Label, Label)
using the minimum operator will give a composition strategy that computes the shortest path connecting two nodes.Usually, strategies require that the two labels provided are of the same kind (i.e., instances of the same
Label
class). Moreover, some strategies only accept label of a certain type, and throw anIllegalArgumentException
if the type is wrong.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Label
add(Label first, Label second)
Adds two given labels; either label may benull
, but not both.Label
multiply(Label first, Label second)
Multiply two given labels; either label may benull
, but not both.Label
one()
Returns the one ofmultiply(Label, Label)
.Label
zero()
Returns the zero ofadd(Label, Label)
.
-
-
-
Method Detail
-
multiply
Label multiply(Label first, Label second)
Multiply two given labels; either label may benull
, but not both. Implementing classes may decide to throw anIllegalArgumentException
if the labels provided are not of the same type, or not of a specific type.- Parameters:
first
- the first label to be multiplied.second
- the second label to be multiplied.- Returns:
- the resulting label (note that the returned label may be reused by the
implementing class, so users are invited to make a
Label.copy()
of it if they need to keep the label in between calls).
-
add
Label add(Label first, Label second)
Adds two given labels; either label may benull
, but not both. Implementing classes may decide to throw anIllegalArgumentException
if the labels provided are not of the same type, or not of a specific type.- Parameters:
first
- the first label to be added.second
- the second label to be added.- Returns:
- the resulting label (note that the returned label may be reused by the
implementing class, so users are invited to make a
Label.copy()
of it if they need to keep the label in between calls).
-
zero
Label zero()
Returns the zero ofadd(Label, Label)
.- Returns:
- the zero of
add(Label, Label)
.
-
one
Label one()
Returns the one ofmultiply(Label, Label)
.- Returns:
- the one of
multiply(Label, Label)
.
-
-