Implementation of the Planar-Straight layout algorithm. More...
#include <ogdf/planarlayout/PlanarStraightLayout.h>
Public Member Functions | |
PlanarStraightLayout () | |
Constructs an instance of the Planar-Straight layout algorithm. More... | |
~PlanarStraightLayout () | |
Optional parameters | |
bool | sizeOptimization () const |
Returns the current setting of option sizeOptimization. More... | |
void | sizeOptimization (bool opt) |
Sets the option sizeOptimization to opt . More... | |
double | baseRatio () const |
Returns the current setting of option baseRatio. More... | |
void | baseRatio (double ratio) |
Sets the option baseRatio to ratio . More... | |
Module options | |
void | setAugmenter (AugmentationModule *pAugmenter) |
Sets the augmentation module. More... | |
void | setShellingOrder (ShellingOrderModule *pOrder) |
Sets the shelling order module. More... | |
void | setEmbedder (EmbedderModule *pEmbedder) |
Sets the module option for the graph embedding algorithm. More... | |
Public Member Functions inherited from ogdf::PlanarGridLayoutModule | |
PlanarGridLayoutModule () | |
Initializes a planar grid layout module. More... | |
virtual | ~PlanarGridLayoutModule () |
void | callFixEmbed (GraphAttributes &AG, adjEntry adjExternal=nullptr) |
Calls the grid layout algorithm with a fixed planar embedding (general call). More... | |
void | callGridFixEmbed (const Graph &G, GridLayout &gridLayout, adjEntry adjExternal=nullptr) |
Calls the grid layout algorithm with a fixed planar embedding (call for GridLayout). More... | |
Public Member Functions inherited from ogdf::GridLayoutModule | |
GridLayoutModule () | |
Initializes a grid layout module. More... | |
virtual | ~GridLayoutModule () |
virtual void | call (GraphAttributes &GA) override final |
Calls the grid layout algorithm (general call). More... | |
void | callGrid (const Graph &G, GridLayout &gridLayout) |
Calls the grid layout algorithm (call for GridLayout). More... | |
const IPoint & | gridBoundingBox () const |
double | separation () const |
Returns the current setting of the minimum distance between nodes. More... | |
void | separation (double sep) |
Sets the minimum distance between nodes. More... | |
Public Member Functions inherited from ogdf::LayoutModule | |
LayoutModule () | |
Initializes a layout module. More... | |
virtual | ~LayoutModule () |
void | operator() (GraphAttributes &GA) |
Computes a layout of graph GA . More... | |
Private Member Functions | |
void | computeCoordinates (const Graph &G, ShellingOrder &lmc, NodeArray< int > &x, NodeArray< int > &y) |
virtual void | doCall (const Graph &G, adjEntry adjExternal, GridLayout &gridLayout, IPoint &boundingBox, bool fixEmbedding) override |
Implements the algorithm call. More... | |
Private Attributes | |
std::unique_ptr< AugmentationModule > | m_augmenter |
The augmentation module. More... | |
double | m_baseRatio |
The option for specifying the base ratio. More... | |
std::unique_ptr< ShellingOrderModule > | m_computeOrder |
The shelling order module. More... | |
std::unique_ptr< EmbedderModule > | m_embedder |
The planar embedder module. More... | |
bool | m_sizeOptimization |
The option for size optimization. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ogdf::PlanarGridLayoutModule | |
virtual void | doCall (const Graph &G, GridLayout &gridLayout, IPoint &boundingBox) override |
Implements the GridLayoutModule::doCall(). More... | |
bool | handleTrivial (const Graph &G, GridLayout &gridLayout, IPoint &boundingBox) |
Handles the special cases of graphs with less than 3 nodes. More... | |
Protected Attributes inherited from ogdf::GridLayoutModule | |
IPoint | m_gridBoundingBox |
The computed bounding box of the grid layout. More... | |
Implementation of the Planar-Straight layout algorithm.
The class PlanarStraightLayout implements a straight-line drawing algorithm for planar graphs. It draws a planar graph on a grid of size at most (2n-4) * (n-2) without edge crossings.
The algorithm runs in several phases. In the first phase, the graph is augmented by adding edges to achieve a certain connectivity (e.g., biconnected or triconnected). Then, a shelling order of the the resulting graph is computed. Both phases are implemented by using module options, so you can replace them with different implementations. However, you have to make sure, that the connectivity achieved by the augmentation module is sufficient for the shelling order module (or the input graph already has the required connectivity).
The implementation used in PlanarStraightLayout is an improved version of an algorithm presented in:
Goos Kant: Drawing Planar Graphs Using the Canonical Ordering. Algorithmica 16(1), pp. 4-32, 1996.
The input graph needs to be planar and simple (i.e., no self-loops and no multiple edges).
Option | Type | Default | Description |
---|---|---|---|
sizeOptimization | bool | true | If this option is set to true, the algorithm tries to reduce the size of the resulting grid layout. |
baseRatio | double | 0.33 | This option specifies the maximal number of nodes placed on the base line. The algorithm tries to place as many nodes as possible on the base line, but takes at most max(2, baseRatio * size of external face) many. |
Instances of type PlanarDrawLayout provide the following module options:
Option | Type | Default | Description |
---|---|---|---|
augmenter | AugmentationModule | PlanarAugmentation | Augments the graph by adding edges to obtain a planar graph with a certain connectivity (e.g., biconnected or triconnected). |
embedder | EmbedderModule | SimpleEmbedder | Planar embedding algorithm applied after planar augmentation. |
shellingOrder | ShellingOrderModule | BiconnectedShellingOrder | The algorithm to compute a shelling order. The connectivity assured by the planar augmentation module has to be sufficient for the shelling order module! |
The computation of the layout takes time O(n), where n is the number of nodes of the input graph.
Definition at line 117 of file PlanarStraightLayout.h.
ogdf::PlanarStraightLayout::PlanarStraightLayout | ( | ) |
Constructs an instance of the Planar-Straight layout algorithm.
|
inline |
Definition at line 122 of file PlanarStraightLayout.h.
|
inline |
Returns the current setting of option baseRatio.
This option specifies the maximal number of nodes placed on the base line. The algorithm tries to place as many nodes as possible on the base line, but takes at most max(2, m_baseRatio * size of external face) many.
Definition at line 147 of file PlanarStraightLayout.h.
|
inline |
Sets the option baseRatio to ratio
.
Definition at line 150 of file PlanarStraightLayout.h.
|
private |
|
overrideprivatevirtual |
Implements the algorithm call.
A derived algorithm must implement this method and return the computed grid layout in gridLayout
.
G | is the input graph. |
adjExternal | is an adjacency entry on the external face, or 0 if no external face is specified. |
gridLayout | is assigned the computed grid layout. |
boundingBox | returns the bounding box of the grid layout. The lower left corner of the bounding box is always (0,0), thus this IPoint defines the upper right corner as well as the width and height of the grid layout. |
fixEmbedding | determines if the input graph is embedded and that embedding has to be preserved (true), or if an embedding needs to be computed (false). |
Implements ogdf::PlanarGridLayoutModule.
|
inline |
Sets the augmentation module.
The augmentation module needs to make sure that the graph gets the connectivity required for calling the shelling order module.
Definition at line 163 of file PlanarStraightLayout.h.
|
inline |
Sets the module option for the graph embedding algorithm.
Definition at line 169 of file PlanarStraightLayout.h.
|
inline |
Sets the shelling order module.
Definition at line 166 of file PlanarStraightLayout.h.
|
inline |
Returns the current setting of option sizeOptimization.
If this option is set to true, the algorithm tries to reduce the size of the resulting grid layout.
Definition at line 135 of file PlanarStraightLayout.h.
|
inline |
Sets the option sizeOptimization to opt
.
Definition at line 138 of file PlanarStraightLayout.h.
|
private |
The augmentation module.
Definition at line 178 of file PlanarStraightLayout.h.
|
private |
The option for specifying the base ratio.
Definition at line 175 of file PlanarStraightLayout.h.
|
private |
The shelling order module.
Definition at line 179 of file PlanarStraightLayout.h.
|
private |
The planar embedder module.
Definition at line 177 of file PlanarStraightLayout.h.
|
private |
The option for size optimization.
Definition at line 174 of file PlanarStraightLayout.h.