public abstract class AbstractMISLabeling extends AbstractLabeling
Different optimization strategies are available; an optimization strategy defines which criteria the algorithm should try to optimize. For example, reducing the number of overlaps between labels and nodes may be considered more important than reducing the number of overlaps between labels and edges.
GenericLabeling| Modifier and Type | Field and Description |
|---|---|
protected Map<Object,Object> |
boxesToNodes
The mapping from the
LabelCandidates to the corresponding nodes in the conflictGraph. |
protected Graph |
conflictGraph
The conflict graph modeling
LabelCandidates as nodes and edges between them as conflicts, i.e., overlaps among candidates. |
protected LayoutGraph |
graph
The input graph that will be labeled.
|
protected INodeMap |
nodesToBoxes
The mapping from each node in the
conflictGraph to the corresponding LabelCandidate instance. |
protected INodeMap |
nodesToID
The mapping from nodes in the
conflictGraph to a corresponding integer value (ID). |
LABEL_MODEL_DPKEY| Constructor and Description |
|---|
AbstractMISLabeling()
Creates a new
AbstractMISLabeling instance with default settings. |
| Modifier and Type | Method and Description |
|---|---|
protected INodeMap |
assignProfit()
Returns a
INodeMap which assigns a profit value to each node in the conflict graph. |
protected void |
createEdges()
Creates the edges in the conflict graph, i.e., one edge between two nodes if the corresponding
LabelCandidates intersect. |
protected void |
foundEdgeOverlap(LabelCandidate labelCandidate,
Edge edge,
LineSegment eSegment)
Indicates that an overlap between a
LabelCandidate and an Edge of the input graph has been found. |
protected void |
foundHaloOverlap(LabelCandidate labelCandidate,
Node node,
YRectangle haloRect)
Indicates that an overlap between a
LabelCandidate and a NodeHalo of the input graph has been found. |
protected void |
foundLabelOverlap(LabelCandidate candidate1,
LabelCandidate candidate2,
Edge edge)
Indicates that an overlap between two
LabelCandidates has been found. |
protected void |
foundNodeOverlap(LabelCandidate labelCandidate,
Node node,
YRectangle nodeBox)
Indicates that an overlap between a
LabelCandidate and a Node of the input graph has been found. |
double |
getCustomProfitModelRatio()
Gets the ratio between the internal profit (ip) and the profit computed using the specified
profit model
(sp). |
OptimizationStrategy |
getOptimizationStrategy()
Gets the optimization strategy which defines the importance of criteria when optimizing labeling results.
|
boolean |
isAmbiguityReductionEnabled()
Gets whether or not the number of ambiguous label placements is reduced by applying an additional optimization step.
|
boolean |
isEdgeOverlapsRemovalEnabled()
Gets whether or not
label candidates that overlap with edges are removed. |
boolean |
isNodeOverlapsRemovalEnabled()
Gets whether or not
label candidates that overlap with nodes are removed. |
void |
setAmbiguityReductionEnabled(boolean value)
Sets whether or not the number of ambiguous label placements is reduced by applying an additional optimization step.
|
void |
setCustomProfitModelRatio(double value)
Sets the ratio between the internal profit (ip) and the profit computed using the specified
profit model
(sp). |
void |
setEdgeOverlapsRemovalEnabled(boolean value)
Sets whether or not
label candidates that overlap with edges are removed. |
void |
setNodeOverlapsRemovalEnabled(boolean value)
Sets whether or not
label candidates that overlap with nodes are removed. |
void |
setOptimizationStrategy(OptimizationStrategy value)
Sets the optimization strategy which defines the importance of criteria when optimizing labeling results.
|
applyLayout, getAffectedLabelsDpKey, getProfit, getProfitModel, isAutoFlippingEnabled, isEdgeGroupOverlapAllowed, isEdgeLabelPlacementEnabled, isInternalNodeLabelMovingEnabled, isLabelOverlapsReducingEnabled, isNodeLabelPlacementEnabled, label, label, label, setAffectedLabelsDpKey, setAutoFlippingEnabled, setEdgeGroupOverlapAllowed, setEdgeLabelPlacementEnabled, setInternalNodeLabelMovingEnabled, setLabelOverlapsReducingEnabled, setNodeLabelPlacementEnabled, setProfitModelapplyLayoutCore, getCoreLayout, setCoreLayoutprotected Map<Object,Object> boxesToNodes
LabelCandidates to the corresponding nodes in the conflictGraph.conflictGraphprotected Graph conflictGraph
LabelCandidates as nodes and edges between them as conflicts, i.e., overlaps among candidates.createEdges()protected LayoutGraph graph
protected INodeMap nodesToBoxes
conflictGraph to the corresponding LabelCandidate instance.conflictGraphprotected INodeMap nodesToID
conflictGraph to a corresponding integer value (ID).
The ID denotes the actual label which a LabelCandidate (i.e. a node in the conflict graph) belongs to.
public AbstractMISLabeling()
AbstractMISLabeling instance with default settings.protected INodeMap assignProfit()
INodeMap which assigns a profit value to each node in the conflict graph.
As the conflict graph's nodes represent LabelCandidates, this mapping gives the profit value of label
candidates. The assigned value is defined as the difference between the profit induced by the profit model
and the candidate's overlap penalty.
The returned map is a mapping from each Node (representing a label candidate) in the conflictGraph to a
Double representing the profit value of the candidate.
protected void createEdges()
LabelCandidates intersect.
The nodes of the conflict graph represent
LabelCandidates. An edge between candidates signals that they overlap. A maximum independent set will be
computed on the conflict graph to choose candidates such that no two candidates overlap.
This method may be overridden to change the structure of the conflict graph. Edges between two
LabelCandidates in the conflict graph signal that the two candidates should not be selected together. By
overriding this method, arbitrary reasons for indicating that two label candidates should not be chosen at the same time
can be modeled.
foundEdgeOverlap(LabelCandidate, Edge, LineSegment),
foundHaloOverlap(LabelCandidate, Node, YRectangle), foundLabelOverlap(LabelCandidate, LabelCandidate, Edge)
and foundNodeOverlap(LabelCandidate, Node, YRectangle) will be invoked when finding an intersection of a
certain type. The mentioned methods will influence the profit of
label candidates. This should be kept in mind when overriding this method.conflictGraph,
nodesToBoxes,
boxesToNodes,
nodesToIDprotected void foundEdgeOverlap(LabelCandidate labelCandidate, Edge edge, LineSegment eSegment)
LabelCandidate and an Edge of the input graph has been found.
This method is called when finding overlaps while creating edges of the
conflict graph. It will store a factor indicating how much the two elements overlap. The
factor influences the profit assigned to the given label candidate.
This method may be overridden to realize a custom strategy for reacting to overlaps between label candidates and edges.
OptimizationStrategy.NONE is chosen as
optimization strategy.labelCandidate - the LabelCandidate overlapping with the given Edgeedge - the Edge overlapping with the given LabelCandidateeSegment - the LineSegment of the given edge overlapping with the given candidateconflictGraph,
createEdges()protected void foundHaloOverlap(LabelCandidate labelCandidate, Node node, YRectangle haloRect)
LabelCandidate and a NodeHalo of the input graph has been found.
This method is called when finding overlaps while creating edges of the
conflict graph. It will store a factor indicating how much the two elements overlap. The
factor influences the profit assigned to the given label candidate.
This method may be overridden to realize a custom strategy for reacting to overlaps between label candidates and node halos.
OptimizationStrategy.NONE is chosen as
optimization strategy.labelCandidate - the LabelCandidate overlapping with a node halonode - the Node whose NodeHalo is overlapping with the given label candidatehaloRect - the bounding box of the NodeHalo overlapping with the given label candidateconflictGraph,
createEdges()protected void foundLabelOverlap(LabelCandidate candidate1, LabelCandidate candidate2, Edge edge)
LabelCandidates has been found.
This method is called when finding overlaps while creating edges of the
conflict graph. It will store a factor indicating how much the two candidates overlap. The
factor influences the penalty assigned when both candidates are chosen, i.e., the penalty for the corresponding
overlap.
This method may be overridden to realize a custom strategy for reacting to overlaps among LabelCandidates.
OptimizationStrategy.NONE is chosen as
optimization strategy.candidate1 - the first overlapping LabelCandidatecandidate2 - the second overlapping LabelCandidateedge - the Edge in conflictGraph representing the found overlapconflictGraph,
createEdges()protected void foundNodeOverlap(LabelCandidate labelCandidate, Node node, YRectangle nodeBox)
LabelCandidate and a Node of the input graph has been found.
This method is called when finding overlaps while creating edges of the
conflict graph. It will store a factor indicating how much the two elements overlap. The
factor influences the profit assigned to the given label candidate.
This method may be overridden to realize a custom strategy for reacting to overlaps between label candidates and nodes.
OptimizationStrategy.NONE is chosen as
optimization strategy.labelCandidate - the LabelCandidate overlapping with the given nodenode - the Node overlapping with the given label candidatenodeBox - the bounding box of the given nodeconflictGraph,
createEdges()public double getCustomProfitModelRatio()
profit model
(sp).
This ratio defines how to weight the two profit values (ip) and (sp). The overall ratio is then computed as
ratio * sp + (1 - ratio) * ip. The profit of a LabelCandidate defines how likely it is that the
candidate will be chosen as actual label position.
The ratio is defined to be a value from the interval [0,1].
IllegalArgumentException - if the given ratio is negative or larger than 1profit model is null or if OptimizationStrategy.NONE
is chosen as optimization strategy.[0,1]) between the internal profit and the profit calculated using the current profit modelAbstractLabeling.setProfitModel(IProfitModel),
setOptimizationStrategy(OptimizationStrategy),
setCustomProfitModelRatio(double)public OptimizationStrategy getOptimizationStrategy()
Depending on the strategy, criteria like label-node overlaps, label-label overlaps and others are more or less
important. For example, if the number of overlaps between labels and nodes is the most important criterion for the
result, strategy OptimizationStrategy.NODE_OVERLAP should be chosen.
IllegalArgumentException - if the given strategy is unknownoptimization step.OptimizationStrategy.BALANCEDsetOptimizationStrategy(OptimizationStrategy)public boolean isAmbiguityReductionEnabled()
A label position is considered to be ambiguous if it might not be possible to identify to which graph element the label belongs. For example, an edge label placed in between two edges is ambiguous.
Enabling this reduction step does not guarantee that no ambiguous placements are selected. The algorithm will try to
avoid them if other good positions without ambiguity are available. Other aspects like preferred placement
for edge labels will still be more important than the reduction of ambiguity.
LabelCandidates.OptimizationStrategy.NONE is selected as
optimization strategy.false. Ambiguous label placements might be selected.true if the algorithm tries to avoid ambiguous label placements, false otherwisesetAmbiguityReductionEnabled(boolean)public boolean isEdgeOverlapsRemovalEnabled()
label candidates that overlap with edges are removed.
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with edges may increase the runtime of this algorithm.
isEdgeOverlapsRemovalEnabled in class AbstractLabelingDefaultParameter
for node labels and DefaultParameter for
edge labels).OptimizationStrategy.NONE set as optimization
strategy, i.e., without optimization. If used together with optimization, the optimization strategy may be restricted
too much and not deliver as good results as it could otherwise do.false. Candidates overlapping with edges are allowed.true if candidates overlapping with edges are removed, false otherwisesetEdgeOverlapsRemovalEnabled(boolean)public boolean isNodeOverlapsRemovalEnabled()
label candidates that overlap with nodes are removed.
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with nodes may increase the runtime of this algorithm.
isNodeOverlapsRemovalEnabled in class AbstractLabelingDefaultParameter
for node labels and DefaultParameter for
edge labels).OptimizationStrategy.NONE set as optimization
strategy, i.e., without optimization. If used together with optimization, the optimization strategy may be restricted
too much and not deliver as good results as it could otherwise do.false. Candidates overlapping with nodes are allowed.true if candidates overlapping with nodes are removed, false otherwisesetNodeOverlapsRemovalEnabled(boolean)public void setAmbiguityReductionEnabled(boolean value)
A label position is considered to be ambiguous if it might not be possible to identify to which graph element the label belongs. For example, an edge label placed in between two edges is ambiguous.
Enabling this reduction step does not guarantee that no ambiguous placements are selected. The algorithm will try to
avoid them if other good positions without ambiguity are available. Other aspects like preferred placement
for edge labels will still be more important than the reduction of ambiguity.
LabelCandidates.OptimizationStrategy.NONE is selected as
optimization strategy.false. Ambiguous label placements might be selected.value - true if the algorithm tries to avoid ambiguous label placements, false otherwiseisAmbiguityReductionEnabled()public void setCustomProfitModelRatio(double value)
profit model
(sp).
This ratio defines how to weight the two profit values (ip) and (sp). The overall ratio is then computed as
ratio * sp + (1 - ratio) * ip. The profit of a LabelCandidate defines how likely it is that the
candidate will be chosen as actual label position.
The ratio is defined to be a value from the interval [0,1].
IllegalArgumentException - if the given ratio is negative or larger than 1profit model is null or if OptimizationStrategy.NONE
is chosen as optimization strategy.value - the ratio (from the interval
[0,1]) between the internal profit and the profit calculated using the current profit modelAbstractLabeling.setProfitModel(IProfitModel),
setOptimizationStrategy(OptimizationStrategy),
getCustomProfitModelRatio()public void setEdgeOverlapsRemovalEnabled(boolean value)
label candidates that overlap with edges are removed.
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with edges may increase the runtime of this algorithm.
setEdgeOverlapsRemovalEnabled in class AbstractLabelingDefaultParameter
for node labels and DefaultParameter for
edge labels).OptimizationStrategy.NONE set as optimization
strategy, i.e., without optimization. If used together with optimization, the optimization strategy may be restricted
too much and not deliver as good results as it could otherwise do.false. Candidates overlapping with edges are allowed.value - true if candidates overlapping with edges are removed, false otherwiseisEdgeOverlapsRemovalEnabled()public void setNodeOverlapsRemovalEnabled(boolean value)
label candidates that overlap with nodes are removed.
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with nodes may increase the runtime of this algorithm.
setNodeOverlapsRemovalEnabled in class AbstractLabelingDefaultParameter
for node labels and DefaultParameter for
edge labels).OptimizationStrategy.NONE set as optimization
strategy, i.e., without optimization. If used together with optimization, the optimization strategy may be restricted
too much and not deliver as good results as it could otherwise do.false. Candidates overlapping with nodes are allowed.value - true if candidates overlapping with nodes are removed, false otherwiseisNodeOverlapsRemovalEnabled()public void setOptimizationStrategy(OptimizationStrategy value)
Depending on the strategy, criteria like label-node overlaps, label-label overlaps and others are more or less
important. For example, if the number of overlaps between labels and nodes is the most important criterion for the
result, strategy OptimizationStrategy.NODE_OVERLAP should be chosen.
IllegalArgumentException - if the given strategy is unknownoptimization step.OptimizationStrategy.BALANCEDvalue - one of the predefined optimization strategiesgetOptimizationStrategy()