E
- the type of the edgespublic class MatchingByID<E extends Edge> extends Set<java.lang.Integer> implements java.io.Serializable
Edge
s.
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.
MatchingByID
to serialize a Matching
. If you deserialize a MatchingByID
keep in mind to set the associated graph with
setGraph(Graph)
otherwise the matching is not functioning any more.
cast()
to convert this matching using edge identifiers in a Matching
using concrete Edge
s.Set.DoubleElementParser, Set.FloatElementParser, Set.IntegerElementParser, Set.LongElementParser, Set.NumberElementParser, Set.StringElementParser
Constructor and Description |
---|
MatchingByID(Graph<? extends Vertex,E> graph)
Creates an empty matching.
|
MatchingByID(MatchingByID<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.
|
boolean |
add(int edgeID)
Adds an edge to the matching.
|
boolean |
add(java.lang.Integer edgeID)
Adds an edge to the matching.
|
void |
add(Vertex v1,
Vertex v2)
Adds the edge between the vertex 1 and 2 to the matching.
|
Matching<E> |
cast()
|
MatchingByID<E> |
clone()
Gets a shallow copy of this matching (the elements in the matching are not cloned).
|
int |
getVertexCount()
Gets the number of matched (saturated) vertices.
|
int |
getVertexID(int index)
Gets a matched vertex id.
|
boolean |
isMatched(int vertexID)
Indicates whether the specified vertex is matched (saturated).
|
boolean |
isMatched(Vertex v)
Indicates whether the specified vertex is matched (saturated).
|
boolean |
remove(java.lang.Object o)
Removes an edge from the matching.
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the edges that are part of the given collection.
|
void |
setGraph(Graph<? extends Vertex,E> graph)
Sets the associated graph of the matching.
|
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 MatchingByID(Graph<? extends Vertex,E> graph) throws java.lang.IllegalArgumentException
graph
- the graph its edges can be part of the matchingjava.lang.IllegalArgumentException
- public MatchingByID(MatchingByID<E> m)
m
- the matching as the basepublic void setGraph(Graph<? extends Vertex,E> graph) throws java.lang.IllegalArgumentException
MatchingByID
is deserialized from a byte stream because the associated graph
can not be serialized. If you do not set the associated graph after deserialization the matching is not functioning any more.graph
- the graph its edges can be part of the matching (ensure that this is the one you have used to create the matching)java.lang.IllegalArgumentException
- public boolean add(java.lang.Integer edgeID) throws java.lang.UnsupportedOperationException, java.lang.NullPointerException, java.lang.IllegalArgumentException
add
in interface java.util.Collection<java.lang.Integer>
add
in interface java.util.Set<java.lang.Integer>
add
in class Set<java.lang.Integer>
edgeID
- the edgetrue
if the element could be added otherwise false
java.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.NullPointerException
- java.lang.IllegalArgumentException
- public boolean add(int edgeID) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
edgeID
- the edgejava.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IllegalArgumentException
- public boolean add(E edge) throws java.lang.UnsupportedOperationException, java.lang.NullPointerException, java.lang.IllegalArgumentException
edge
- the edgejava.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.NullPointerException
- java.lang.IllegalArgumentException
- public void add(Vertex v1, Vertex v2) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
v1
- the vertex 1v2
- the vertex 2java.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IllegalArgumentException
- public boolean remove(java.lang.Object o) throws java.lang.UnsupportedOperationException
remove
in interface java.util.Collection<java.lang.Integer>
remove
in interface java.util.Set<java.lang.Integer>
remove
in class Set<java.lang.Integer>
o
- the id of the edge that should be removed from the matchingtrue
if the edge could be removed otherwise false
java.lang.UnsupportedOperationException
- setGraph(Graph)
)public boolean retainAll(java.util.Collection<?> c) throws java.lang.UnsupportedOperationException
retainAll
in interface java.util.Collection<java.lang.Integer>
retainAll
in interface java.util.Set<java.lang.Integer>
retainAll
in class Set<java.lang.Integer>
c
- the collection with the identifiers of the edges that should be retainedtrue
if the edges could be retained otherwise false
java.lang.UnsupportedOperationException
- setGraph(Graph)
)public int getVertexCount()
public int getVertexID(int index) throws java.lang.UnsupportedOperationException, java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IndexOutOfBoundsException
- index < 0 || index >= getVertexCount()
)public boolean isMatched(Vertex v) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
v
- the vertextrue
if the given vertex is an endpoint of an edge in the matching otherwise false
java.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IllegalArgumentException
- public boolean isMatched(int vertexID) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
vertexID
- the vertex idtrue
if the given vertex is an endpoint of an edge in the matching otherwise false
java.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IllegalArgumentException
public Matching<E> cast() throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
- setGraph(Graph)
)java.lang.IllegalArgumentException
- public MatchingByID<E> clone()