Class TwoLayeredBipartiteLayout2D<V,​E>

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

    public class TwoLayeredBipartiteLayout2D<V,​E>
    extends 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.
    Author:
    Dimitrios Michail
    • Field Detail

      • vertexComparator

        protected Comparator<V> vertexComparator
      • vertical

        protected boolean vertical
      • partition

        protected Set<V> partition
    • Constructor Detail

      • TwoLayeredBipartiteLayout2D

        public TwoLayeredBipartiteLayout2D()
        Create a new layout
      • TwoLayeredBipartiteLayout2D

        public TwoLayeredBipartiteLayout2D​(Set<V> partition,
                                           Comparator<V> vertexComparator,
                                           boolean vertical)
        Create a new layout
        Parameters:
        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​(Comparator<V> vertexComparator)
        Adjust the vertex comparator which specifies the vertex order.
        Parameters:
        vertexComparator - the vertex comparator, or null in order to use the graph ordering
        Returns:
        the layout algorithm instance
      • withVertical

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

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

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