java.lang.Object
org.variantsync.diffdetective.variation.diff.serialize.edgeformat.EdgeLabelFormat<L>
All Implemented Interfaces:
LinegraphFormat
Direct Known Subclasses:
ChildOrderEdgeFormat, DefaultEdgeLabelFormat, DirectedEdgeLabelFormat

public abstract class EdgeLabelFormat<L extends Label> extends Object implements LinegraphFormat
Reads and writes edges between DiffNodes from and to line graph.
Author:
Kevin Jedelhauser, Paul Maximilian Bittner
  • Field Details

  • Constructor Details

    • EdgeLabelFormat

      public EdgeLabelFormat()
      Creates a new format with the default direction.
    • EdgeLabelFormat

      public EdgeLabelFormat(EdgeLabelFormat.Direction direction)
      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

      public void setEdgeDirection(EdgeLabelFormat.Direction direction)
      Set the direction for edge IO.
    • getEdgeDirection

      public EdgeLabelFormat.Direction 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 (via DiffNode.addChild(DiffNode, Time)) In particular, this method checks if the given edge label starts with LineGraphConstants.BEFORE_PARENT, LineGraphConstants.AFTER_PARENT, or LineGraphConstants.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 IllegalArgumentException
      Parses 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

      public abstract <La extends L> String labelOf(StyledEdge<La> edge)
      Converts a StyledEdge into a label suitable for exporting. This may be human readable text or machine parseable metadata.
      Parameters:
      edge - The StyledEdge to be labeled
      Returns:
      a label for edge
    • multilineLabelOf

      public <La extends L> List<String> multilineLabelOf(StyledEdge<La> edge)
      Converts a StyledEdge 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 - The StyledEdge to be labeled
      Returns:
      a list of lines of the label for edge