Module org.jgrapht.core
Package org.jgrapht.alg.spanning
Class AbstractCapacitatedMinimumSpanningTree.CapacitatedSpanningTreeSolutionRepresentation
java.lang.Object
org.jgrapht.alg.spanning.AbstractCapacitatedMinimumSpanningTree.CapacitatedSpanningTreeSolutionRepresentation
- All Implemented Interfaces:
- java.lang.Cloneable
- Enclosing class:
- AbstractCapacitatedMinimumSpanningTree<V,E>
protected class AbstractCapacitatedMinimumSpanningTree.CapacitatedSpanningTreeSolutionRepresentation
extends java.lang.Object
implements java.lang.Cloneable
This class represents a solution instance by managing the labels and the partition mapping.
 With the help of this class, a capacitated spanning tree based on the label and partition
 mapping can be calculated.
- 
Constructor SummaryConstructors Constructor Description CapacitatedSpanningTreeSolutionRepresentation()Constructs a new solution representation for the CMST problem.CapacitatedSpanningTreeSolutionRepresentation(java.util.Map<V,java.lang.Integer> labels, java.util.Map<java.lang.Integer,Pair<java.util.Set<V>,java.lang.Double>> partition)Constructs a new solution representation for the CMST problem based onlabelsandpartition.
- 
Method SummaryModifier and Type Method Description CapacitatedSpanningTreeAlgorithm.CapacitatedSpanningTree<V,E>calculateResultingSpanningTree()Calculates the resulting spanning tree based on this solution representation.voidcleanUp()Cleans up the solution representation by removing all empty sets from the partition.AbstractCapacitatedMinimumSpanningTree.CapacitatedSpanningTreeSolutionRepresentationclone()Returns a shallow copy of this solution representation instance.intgetLabel(V vertex)Returns the label of the subset that containsvertex.java.util.Set<java.lang.Integer>getLabels()Returns all labels of all subsets.intgetNextFreeLabel()Returns the next free label in the label map respectively partitionjava.util.Set<V>getPartitionSet(java.lang.Integer label)Returns the set of vertices that are in the subset with labellabel.doublegetPartitionWeight(java.lang.Integer label)Returns the sum of the weights of all vertices that are in the subset with labellabel.voidmoveVertex(V vertex, java.lang.Integer fromLabel, java.lang.Integer toLabel)Movesvertexfrom the subset represented byfromLabelto the subset represented bytoLabel.voidmoveVertices(java.util.Set<V> vertices, java.lang.Integer fromLabel, java.lang.Integer toLabel)Moves all vertices inverticesfrom the subset represented byfromLabelto the subset represented bytoLabel.java.util.Set<java.lang.Integer>partitionSubtreesOfSubset(java.util.Set<V> vertexSubset, int label)Refines the partition by adding new subsets if the designated root has more than one subtree in the subsetlabelof the partition.
- 
Constructor Details- 
CapacitatedSpanningTreeSolutionRepresentationpublic CapacitatedSpanningTreeSolutionRepresentation()Constructs a new solution representation for the CMST problem.
- 
CapacitatedSpanningTreeSolutionRepresentationpublic CapacitatedSpanningTreeSolutionRepresentation(java.util.Map<V,java.lang.Integer> labels, java.util.Map<java.lang.Integer,Pair<java.util.Set<V>,java.lang.Double>> partition)Constructs a new solution representation for the CMST problem based onlabelsandpartition. All labels have to be positive.- Parameters:
- labels- the labels of the subsets in the partition
- partition- the partition map
 
 
- 
- 
Method Details- 
calculateResultingSpanningTreepublic CapacitatedSpanningTreeAlgorithm.CapacitatedSpanningTree<V,E> calculateResultingSpanningTree()Calculates the resulting spanning tree based on this solution representation.- Returns:
- the resulting spanning tree based on this solution representation
 
- 
moveVertexMovesvertexfrom the subset represented byfromLabelto the subset represented bytoLabel.- Parameters:
- vertex- the vertex to move
- fromLabel- the subset to move the vertex from
- toLabel- the subset to move the vertex to
 
- 
moveVerticespublic void moveVertices(java.util.Set<V> vertices, java.lang.Integer fromLabel, java.lang.Integer toLabel)Moves all vertices inverticesfrom the subset represented byfromLabelto the subset represented bytoLabel.- Parameters:
- vertices- the vertices to move
- fromLabel- the subset to move the vertices from
- toLabel- the subset to move the vertices to
 
- 
partitionSubtreesOfSubsetpublic java.util.Set<java.lang.Integer> partitionSubtreesOfSubset(java.util.Set<V> vertexSubset, int label)Refines the partition by adding new subsets if the designated root has more than one subtree in the subsetlabelof the partition.- Parameters:
- vertexSubset- the subset represented by- label, that is the subset that has to be refined
- label- the label of the subset of the partition that were refined
- Returns:
- the set of all labels of subsets that were changed during the refinement
 
- 
cleanUppublic void cleanUp()Cleans up the solution representation by removing all empty sets from the partition.
- 
getNextFreeLabelpublic int getNextFreeLabel()Returns the next free label in the label map respectively partition- Returns:
- the next free label in the label map respectively partition
 
- 
getLabelReturns the label of the subset that containsvertex.- Parameters:
- vertex- the vertex to return the label from
- Returns:
- the label of vertex
 
- 
getLabelspublic java.util.Set<java.lang.Integer> getLabels()Returns all labels of all subsets.- Returns:
- the labels of all subsets
 
- 
getPartitionSetReturns the set of vertices that are in the subset with labellabel.- Parameters:
- label- the label of the subset to return the vertices from
- Returns:
- the set of vertices that are in the subset with label label
 
- 
getPartitionWeightpublic double getPartitionWeight(java.lang.Integer label)Returns the sum of the weights of all vertices that are in the subset with labellabel.- Parameters:
- label- the label of the subset to return the weight from
- Returns:
- the sum of the weights of all vertices that are in the subset with label
         label
 
- 
cloneReturns a shallow copy of this solution representation instance. Vertices are not cloned.- Overrides:
- clonein class- java.lang.Object
- Returns:
- a shallow copy of this solution representation.
- Throws:
- java.lang.RuntimeException- in case the clone is not supported
- See Also:
- Object.clone()
 
 
-