E
- the type of the edgespublic class Matching<E extends Edge> extends Set<E>
G = (V, E)
, a matching M
is a subset of E
that is, no two edges share a common vertex.V
is matched (or saturated) if it is an endpoint of one of the edges in the matching otherwise the vertex is unmatched.
cast()
to convert this matching using concrete Edge
s in a MatchingByID
using edge indentifiers.
GraphUtils.isAugmentingPath(lavesdk.math.graph.Path, Matching)
to check whether a path is an augmenting path on a given matching.Set.DoubleElementParser, Set.FloatElementParser, Set.IntegerElementParser, Set.LongElementParser, Set.NumberElementParser, Set.StringElementParser
Constructor and Description |
---|
Matching(Graph<? extends Vertex,E> graph)
Creates an empty matching.
|
Matching(Matching<E> m)
Creates a matching based on another matching meaning the elements of the base matching are added to this matching.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E edge)
Adds an edge to the matching.
|
void |
add(Vertex v1,
Vertex v2)
Adds the edge between the vertex 1 and 2 to the matching.
|
MatchingByID<E> |
cast()
Converts this matching using concrete
Edge s in a MatchingByID using edge identifiers. |
Matching<E> |
clone()
Gets a shallow copy of this matching (the elements in the matching are not cloned).
|
Vertex |
getVertex(int index)
Gets a matched vertex.
|
int |
getVertexCount()
Gets the number of matched (saturated) vertices.
|
boolean |
isMatched(Vertex v)
Indicates whether the specified vertex is matched (saturated).
|
boolean |
remove(java.lang.Object o) |
boolean |
retainAll(java.util.Collection<?> c) |
java.lang.String |
toString() |
addAll, addAll, asList, clear, complement, contains, containsAll, containsAll, equals, equals, get, hashCode, intersection, intersection, intersection, isEmpty, iterator, parse, parse, removeAll, removeAll, retainAll, size, symDifference, toArray, toArray, union, union, union
public Matching(Graph<? extends Vertex,E> graph) throws java.lang.IllegalArgumentException
graph
- the graph its edges can be part of the matchingjava.lang.IllegalArgumentException
- public boolean add(E edge) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
add
in interface java.util.Collection<E extends Edge>
add
in interface java.util.Set<E extends Edge>
add
in class Set<E extends Edge>
edge
- the edgetrue
if the element could be added otherwise false
java.lang.NullPointerException
- java.lang.IllegalArgumentException
- public void add(Vertex v1, Vertex v2) throws java.lang.IllegalArgumentException
v1
- the vertex 1v2
- the vertex 2java.lang.IllegalArgumentException
- public boolean remove(java.lang.Object o)
public boolean retainAll(java.util.Collection<?> c)
public int getVertexCount()
public Vertex getVertex(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getVertexCount()
)public boolean isMatched(Vertex v) throws java.lang.IllegalArgumentException
v
- the vertextrue
if the given vertex is an endpoint of an edge in the matching otherwise false
java.lang.IllegalArgumentException
- public MatchingByID<E> cast()
Edge
s in a MatchingByID
using edge identifiers.java.lang.IllegalArgumentException
- public Matching<E> clone()