Class TwoLayeredBipartiteLayout2D<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    Direct Known Subclasses:
    BarycenterGreedyTwoLayeredBipartiteLayout2D, MedianGreedyTwoLayeredBipartiteLayout2D

    public class TwoLayeredBipartiteLayout2D<V,​E>
    extends java.lang.Object
    implements LayoutAlgorithm2D<V,​E>
    A two layered bipartite layout. The algorithm draws a bipartite graph using straight edges. Vertices are arranged along two vertical or horizontal lines. No attempt is made to minimize edge crossings. The order of the vertices can be adjusted by providing a vertex comparator. Similarly the user can also determine the two partitions or can let the algorithm compute them.
    Dimitrios Michail
    • Field Detail

      • vertexComparator

        protected java.util.Comparator<V> vertexComparator
      • vertical

        protected boolean vertical
      • partition

        protected java.util.Set<V> partition
    • Constructor Detail

      • TwoLayeredBipartiteLayout2D

        public TwoLayeredBipartiteLayout2D()
        Create a new layout
      • TwoLayeredBipartiteLayout2D

        public TwoLayeredBipartiteLayout2D​(java.util.Set<V> partition,
                                           java.util.Comparator<V> vertexComparator,
                                           boolean vertical)
        Create a new layout
        partition - one of the two partitions, can be null
        vertexComparator - vertex order, can be null
        vertical - draw on two vertical or horizontal lines
    • Method Detail

      • withVertexComparator

        public TwoLayeredBipartiteLayout2D<V,​E> withVertexComparator​(java.util.Comparator<V> vertexComparator)
        Adjust the vertex comparator which specifies the vertex order.
        vertexComparator - the vertex comparator, or null in order to use the graph ordering
        the layout algorithm instance
      • withVertical

        public TwoLayeredBipartiteLayout2D<V,​E> withVertical​(boolean vertical)
        Adjust whether the layout will be vertical or horizontal.
        vertical - if true vertical, otherwize horizontal
        the layout algorithm instance
      • withFirstPartition

        public TwoLayeredBipartiteLayout2D<V,​E> withFirstPartition​(java.util.Set<V> partition)
        Specify the first of the two bipartite partitions. If not provided, the algorithm computes a partitioning.
        partition - the partition
        the layout algorithm instance
      • drawFirstPartition

        protected void drawFirstPartition​(Graph<V,​E> graph,
                                          java.util.List<V> partition,
                                          LayoutModel2D<V> model)
      • drawSecondPartition

        protected void drawSecondPartition​(Graph<V,​E> graph,
                                           java.util.List<V> partition,
                                           LayoutModel2D<V> model)
      • computePartitions

        protected Pair<java.util.List<V>,​java.util.List<V>> computePartitions​(Graph<V,​E> graph)
        Compute the vertex partitions.
        graph - the input graph
        a pair of two vertex lists