Package org.tinfour.common
Class VertexMergerGroup
- java.lang.Object
-
- org.tinfour.common.Vertex
-
- org.tinfour.common.VertexMergerGroup
-
- All Implemented Interfaces:
ISamplePoint
public class VertexMergerGroup extends Vertex
A synthetic vertex used to handle cases when multiple vertices occupy coincident locations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVertexMergerGroup.ResolutionRuleSpecifies a rule for determining a z value based on the collection of coincident vertices.
-
Field Summary
-
Fields inherited from class org.tinfour.common.Vertex
auxiliary, BIT_CONSTRAINT, BIT_REFINEMENT, BIT_SYNTHETIC, BIT_WITHHELD, reserved0, reserved1, status, x, y
-
-
Constructor Summary
Constructors Constructor Description VertexMergerGroup(Vertex firstVertex)Constructs a coincident vertex using the specified vertex for initialization.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddVertex(Vertex v)Add a new vertex to the coincident collection.booleancontains(Vertex v)Indicates whether the group contains the specified vertexintgetSize()Gets the number of vertices grouped together in the collectionVertex[]getVertices()Gets an array of the coincident vertices.doublegetZ()Get the z value associated with the vertex and the merging rules.booleanremoveVertex(Vertex v)Removes the specified vertex from the group.voidsetAuxiliaryIndex(int auxiliaryIndex)Sets the color index for the vertex.voidsetResolutionRule(VertexMergerGroup.ResolutionRule rule)Sets the rule for resolving coincident vertices; recalculates value for vertex if necessary-
Methods inherited from class org.tinfour.common.Vertex
getAuxiliaryIndex, getDistance, getDistance, getDistanceSq, getDistanceSq, getIndex, getLabel, getStatus, getX, getY, isConstraintMember, isNull, isRefinementProduct, isSynthetic, isWithheld, setConstraintMember, setIndex, setRefinementProduct, setStatus, setSynthetic, setWithheld, toString
-
-
-
-
Constructor Detail
-
VertexMergerGroup
public VertexMergerGroup(Vertex firstVertex)
Constructs a coincident vertex using the specified vertex for initialization.- Parameters:
firstVertex- a valid instance
-
-
Method Detail
-
addVertex
public boolean addVertex(Vertex v)
Add a new vertex to the coincident collection. Recompute z value using current rule.- Parameters:
v- a valid, unique instance- Returns:
- true if added to collection; otherwise false
-
removeVertex
public boolean removeVertex(Vertex v)
Removes the specified vertex from the group. If the vertex is not currently a member of the group, this operation will be ignored.- Parameters:
v- the vertex to be removed.- Returns:
- true if the vertex was a member of the group and was removed; otherwise, false.
-
setResolutionRule
public void setResolutionRule(VertexMergerGroup.ResolutionRule rule)
Sets the rule for resolving coincident vertices; recalculates value for vertex if necessary- Parameters:
rule- a valid member of the enumeration
-
getZ
public double getZ()
Get the z value associated with the vertex and the merging rules. If the vertex is null, the return value for this method is Double.NaN ("not a number").- Specified by:
getZin interfaceISamplePoint- Overrides:
getZin classVertex- Returns:
- a floating point value or Double.NaN if z value is null.
-
getVertices
public Vertex[] getVertices()
Gets an array of the coincident vertices. Each invocation of this method results in a new instance of the array.- Returns:
- a valid array of size 1 or greater.
-
getSize
public int getSize()
Gets the number of vertices grouped together in the collection- Returns:
- normally, a value of 1 or greater; but if the last vertex in the group has been removed, a value of zero.
-
contains
public boolean contains(Vertex v)
Indicates whether the group contains the specified vertex- Parameters:
v- a valid vertex- Returns:
- true if the vertex is a member of the group; otherwise, false.
-
setAuxiliaryIndex
public void setAuxiliaryIndex(int auxiliaryIndex)
Sets the color index for the vertex. The color index field is provided in support of graph-coloring algorithms. Values in the range 0 to 255 are supported.This method will set the color index for all vertices contain within the merger group.
- Overrides:
setAuxiliaryIndexin classVertex- Parameters:
auxiliaryIndex- a value in the range 0 to 255
-
-