Class EdgeLabelFormat<L extends Label>
java.lang.Object
org.variantsync.diffdetective.variation.diff.serialize.edgeformat.EdgeLabelFormat<L>
- All Implemented Interfaces:
LinegraphFormat
- Direct Known Subclasses:
ChildOrderEdgeFormat
,DefaultEdgeLabelFormat
,DirectedEdgeLabelFormat
Reads and writes edges between
DiffNodes
from and to line graph.- Author:
- Kevin Jedelhauser, Paul Maximilian Bittner
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new format with thedefault direction
.EdgeLabelFormat
(EdgeLabelFormat.Direction direction) Creates a new format that uses the given direction for edge export and import. -
Method Summary
Modifier and TypeMethodDescription<La extends L>
voidParses the edge in the given lineGraphLine.protected <La extends L>
voidconnectAccordingToLabel
(DiffNode<La> child, DiffNode<La> parent, String edgeLabel) Adds the given child node as the child of the given parent node for all times described by the given label (viaDiffNode.addChild(DiffNode, Time)
) In particular, this method checks if the given edge label starts withLineGraphConstants.BEFORE_PARENT
,LineGraphConstants.AFTER_PARENT
, orLineGraphConstants.BEFORE_AND_AFTER_PARENT
and connects both nodes accordingly.Returns the direction, edges in linegraph files are interpreted to have.labelOf
(StyledEdge<La> edge) Converts aStyledEdge
into a label suitable for exporting.multilineLabelOf
(StyledEdge<La> edge) Converts aStyledEdge
into a multi line label suitable for exporting.void
setEdgeDirection
(EdgeLabelFormat.Direction direction) Set the direction for edge IO.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.variantsync.diffdetective.variation.diff.serialize.LinegraphFormat
getIdentifier, getShortName
-
Field Details
-
edgeDirection
-
-
Constructor Details
-
EdgeLabelFormat
public EdgeLabelFormat()Creates a new format with thedefault direction
. -
EdgeLabelFormat
Creates a new format that uses the given direction for edge export and import.- Parameters:
direction
- The direction in which edges are written and in which read edges are interpreted.
-
-
Method Details
-
setEdgeDirection
Set the direction for edge IO. -
getEdgeDirection
Returns the direction, edges in linegraph files are interpreted to have. -
connectAccordingToLabel
protected <La extends L> void connectAccordingToLabel(DiffNode<La> child, DiffNode<La> parent, String edgeLabel) Adds the given child node as the child of the given parent node for all times described by the given label (viaDiffNode.addChild(DiffNode, Time)
) In particular, this method checks if the given edge label starts withLineGraphConstants.BEFORE_PARENT
,LineGraphConstants.AFTER_PARENT
, orLineGraphConstants.BEFORE_AND_AFTER_PARENT
and connects both nodes accordingly.- Parameters:
child
- The node that should be the child of the given parent at the times described by the label.parent
- The node that should be the parent of the given child at the times described by the label.edgeLabel
- The label that describes the time, the edge exists at, by being prefixed with one of the LineGraphConstants described above.
-
connect
public <La extends L> void connect(String lineGraphLine, Map<Integer, DiffNode<La>> nodes) throws IllegalArgumentExceptionParses the edge in the given lineGraphLine. Connects the two nodes referenced by the edge accordingly. Assumes that both nodes being referenced in the parsed line exist in the given collection.- Parameters:
lineGraphLine
- A line from a line graph file describing an edge.nodes
- All nodes that have been parsed so far, indexed by their id.- Throws:
IllegalArgumentException
- when a node referenced in the lineGraphLine does not exist in the given map.
-
labelOf
Converts aStyledEdge
into a label suitable for exporting. This may be human readable text or machine parseable metadata.- Parameters:
edge
- TheStyledEdge
to be labeled- Returns:
- a label for
edge
-
multilineLabelOf
Converts aStyledEdge
into a multi line label suitable for exporting. This should be human readable text. Use a single line for machine parseable metadata (<La>labelOf(org.variantsync.diffdetective.variation.diff.serialize.StyledEdge<La>)
).- Parameters:
edge
- TheStyledEdge
to be labeled- Returns:
- a list of lines of the label for
edge
-