Drawing¶
Algorithms¶

jgrapht.algorithms.drawing.
circular_layout_2d
(graph, area, radius, vertex_comparator_cb=None)[source]¶ Circular 2d layout.
The algorithm places the graph vertices on a circle evenly spaced. The vertices are iterated based on the iteration order of the vertex set of the graph. The order can be adjusted by providing an external comparator.
 Parameters
graph – the graph to draw
area – the two dimensional area as a tuple (minx, miny, width, height)
radius – radius of the circle
vertex_comparator_cb – a vertex comparator. Should be a function which accepts two vertices v1, v2 and return 1, 0, 1 depending of whether v1 < v2, v1 == v2, or v1 > v2 in the ordering
 Returns
a 2d layout model as an instance of
jgrapht.types.LayoutModel2D
.

jgrapht.algorithms.drawing.
fruchterman_reingold_indexed_layout_2d
(graph, area, iterations=100, normalization_factor=0.5, seed=None, theta=0.5, tolerance=None)[source]¶ Fruchterman and Reingold ForceDirected Placement.
The algorithm belongs in the broad category of force directed graph drawing algorithms and is described in the paper:
Thomas M. J. Fruchterman and Edward M. Reingold. Graph drawing by forcedirected placement. Software: Practice and experience, 21(11):1129–1164, 1991.
This implementation uses the BarnesHut indexing technique with a QuadTree. The BarnesHut indexing technique is described in the following paper:
J. Barnes and P. Hut. A hierarchical O(N log N) forcecalculation algorithm. Nature. 324(4):446–449, 1986.
An inverse linear temperature model is used for the annealing schedule.
 Parameters
graph – the graph to draw
area – the two dimensional area as a tuple (minx, miny, width, height)
iterations – number of iterations
normalization_factor – normalization factor when calculating optimal distance
seed – seed for the random number generator. If None the system time is used
theta – parameter for approximation using the BarnesHut technique
 Parram tolerance
tolerance used when comparing floating point values
 Returns
a 2d layout model as an instance of
jgrapht.types.LayoutModel2D
.

jgrapht.algorithms.drawing.
fruchterman_reingold_layout_2d
(graph, area, iterations=100, normalization_factor=0.5, seed=None)[source]¶ Fruchterman and Reingold ForceDirected Placement.
The algorithm belongs in the broad category of force directed graph drawing algorithms and is described in the paper:
Thomas M. J. Fruchterman and Edward M. Reingold. Graph drawing by forcedirected placement. Software: Practice and experience, 21(11):1129–1164, 1991.
An inverse linear temperature model is used for the annealing schedule.
 Parameters
graph – the graph to draw
area – the two dimensional area as a tuple (minx, miny, width, height)
iterations – number of iterations
normalization_factor – normalization factor when calculating optimal distance
seed – seed for the random number generator. If None the system time is used
 Returns
a 2d layout model as an instance of
jgrapht.types.LayoutModel2D
.

jgrapht.algorithms.drawing.
random_layout_2d
(graph, area, seed=None)[source]¶ Random 2d layout.
The algorithm assigns vertex coordinates uniformly at random.
 Parameters
graph – the graph to draw
area – the two dimensional area as a tuple (minx, miny, width, height)
seed – seed for the random number generator. If None the system time is used
 Returns
a 2d layout model as an instance of
jgrapht.types.LayoutModel2D
.