Class SubgraphDepthLocater.DepthSegment

  • All Implemented Interfaces:
    java.lang.Comparable
    Enclosing class:
    SubgraphDepthLocater

    static class SubgraphDepthLocater.DepthSegment
    extends java.lang.Object
    implements java.lang.Comparable
    A segment from a directed edge which has been assigned a depth value for its sides.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object obj)
      Defines a comparison operation on DepthSegments which orders them left to right.
      private int compareX​(LineSegment seg0, LineSegment seg1)
      Compare two collinear segments for left-most ordering.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • leftDepth

        private int leftDepth
    • Constructor Detail

      • DepthSegment

        public DepthSegment​(LineSegment seg,
                            int depth)
    • Method Detail

      • compareTo

        public int compareTo​(java.lang.Object obj)
        Defines a comparison operation on DepthSegments which orders them left to right. Assumes the segments are normalized.

        The definition of the ordering is:

        • -1 : if DS1.seg is left of or below DS2.seg (DS1 < DS2)
        • 1 : if DS1.seg is right of or above DS2.seg (DS1 > DS2)
        • 0 : if the segments are identical
        KNOWN BUGS:
        • The logic does not obey the Comparator.compareTo contract. This is acceptable for the intended usage, but may cause problems if used with some utilities in the Java standard library (e.g. {@link Collections.sort()}.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        obj - a DepthSegment
        Returns:
        the comparison value
      • compareX

        private int compareX​(LineSegment seg0,
                             LineSegment seg1)
        Compare two collinear segments for left-most ordering. If segs are vertical, use vertical ordering for comparison. If segs are equal, return 0. Segments are assumed to be directed so that the second coordinate is >= to the first (e.g. up and to the right).
        Parameters:
        seg0 - a segment to compare
        seg1 - a segment to compare
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object