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
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
-
Constructor Summary
ConstructorDescriptionCreate a new layoutTwoLayeredBipartiteLayout2D
(Set<V> partition, Comparator<V> vertexComparator, boolean vertical) Create a new layout -
Method Summary
Modifier and TypeMethodDescriptioncomputePartitions
(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 a graph.withFirstPartition
(Set<V> partition) Specify the first of the two bipartite partitions.withVertexComparator
(Comparator<V> vertexComparator) Adjust the vertex comparator which specifies the vertex order.withVertical
(boolean vertical) Adjust whether the layout will be vertical or horizontal.
-
Field Details
-
vertexComparator
-
vertical
protected boolean vertical -
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 nullvertexComparator
- vertex order, can be nullvertical
- draw on two vertical or horizontal lines
-
-
Method Details
-
withVertexComparator
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
Adjust whether the layout will be vertical or horizontal.- Parameters:
vertical
- if true vertical, otherwize horizontal- Returns:
- the layout algorithm instance
-
withFirstPartition
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
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
-
drawSecondPartition
-
computePartitions
Compute the vertex partitions.- Parameters:
graph
- the input graph- Returns:
- a pair of two vertex lists
-