- java.lang.Object
-
- org.jgrapht.alg.drawing.TwoLayeredBipartiteLayout2D<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- 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 Summary
Fields Modifier and Type Field Description protected Set<V>
partition
protected Comparator<V>
vertexComparator
protected boolean
vertical
-
Constructor Summary
Constructors Constructor Description TwoLayeredBipartiteLayout2D()
Create a new layoutTwoLayeredBipartiteLayout2D(Set<V> partition, Comparator<V> vertexComparator, boolean vertical)
Create a new layout
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Pair<List<V>,List<V>>
computePartitions(Graph<V,E> graph)
Compute the vertex partitions.protected void
drawFirstPartition(Graph<V,E> graph, List<V> partition, LayoutModel2D<V> model)
protected void
drawSecondPartition(Graph<V,E> graph, List<V> partition, LayoutModel2D<V> model)
void
layout(Graph<V,E> graph, LayoutModel2D<V> model)
Layout a graph.TwoLayeredBipartiteLayout2D<V,E>
withFirstPartition(Set<V> partition)
Specify the first of the two bipartite partitions.TwoLayeredBipartiteLayout2D<V,E>
withVertexComparator(Comparator<V> vertexComparator)
Adjust the vertex comparator which specifies the vertex order.TwoLayeredBipartiteLayout2D<V,E>
withVertical(boolean vertical)
Adjust whether the layout will be vertical or horizontal.
-
-
-
Field Detail
-
vertexComparator
protected Comparator<V> vertexComparator
-
vertical
protected boolean vertical
-
-
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 nullvertexComparator
- vertex order, can be nullvertical
- 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
-
layout
public void layout(Graph<V,E> graph, LayoutModel2D<V> model)
Description copied from interface:LayoutAlgorithm2D
Layout a graph.- Specified by:
layout
in interfaceLayoutAlgorithm2D<V,E>
- Parameters:
graph
- the graphmodel
- 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)
-
-