Class TwoLayeredBipartiteLayout2D<V,E>

java.lang.Object
org.jgrapht.alg.drawing.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 Details

    • vertexComparator

      protected Comparator<V> vertexComparator
    • vertical

      protected boolean vertical
    • partition

      protected Set<V> partition
  • Constructor Details

    • 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 Details

    • 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
    • layout

      public void layout(Graph<V,E> graph, LayoutModel2D<V> model)
      Description copied from interface: LayoutAlgorithm2D
      Layout a graph.
      Specified by:
      layout in interface LayoutAlgorithm2D<V,E>
      Parameters:
      graph - the graph
      model - the layout model to use
    • drawFirstPartition

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

      protected void drawSecondPartition(Graph<V,E> graph, List<V> partition, LayoutModel2D<V> model)
    • 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