# OpenGraph DrawingFramework

v. 2022.02 (Dogwood)

ogdf::DavidsonHarelLayout Class Reference

The Davidson-Harel layout algorithm. More...

#include <ogdf/energybased/DavidsonHarelLayout.h>

Inheritance diagram for ogdf::DavidsonHarelLayout:

## Public Types

enum  SettingsParameter { SettingsParameter::Standard, SettingsParameter::Repulse, SettingsParameter::Planar }
Easy way to set fixed costs. More...

enum  SpeedParameter { SpeedParameter::Fast, SpeedParameter::Medium, SpeedParameter::HQ }
Easy way to set temperature and iterations. More...

## Public Member Functions

DavidsonHarelLayout ()
Creates an instance of Davidson-Harel layout. More...

~DavidsonHarelLayout ()

virtual void call (GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA. More...

void fixSettings (SettingsParameter sp)
Fixes the cost values to special configurations. More...

double getAttractionWeight () const
Returns the weight for the energy function Attraction. More...

double getNodeOverlapWeight () const
Returns the weight for the energy function NodeOverlap. More...

int getNumberOfIterations () const
Returns the number of iterations per temperature step. More...

double getPlanarityWeight () const
Returns the weight for the energy function Planarity. More...

double getRepulsionWeight () const
Returns the weight for the energy function Repulsion. More...

int getStartTemperature () const
Returns the starting temperature. More...

void setAttractionWeight (double)
Sets the weight for the energy function Attraction. More...

void setIterationNumberAsFactor (bool b)
Switch between using iteration number as fixed number or factor (*number of nodes of graph) More...

void setNodeOverlapWeight (double)
Sets the weight for the energy function NodeOverlap. More...

void setNumberOfIterations (int steps)
Sets the number of iterations per temperature step to steps. More...

void setPlanarityWeight (double)
Sets the weight for the energy function Planarity. More...

void setPreferredEdgeLength (double elen)
Sets the preferred edge length to elen. More...

void setPreferredEdgeLengthMultiplier (double multi)
Sets the preferred edge length multiplier for attraction. More...

void setRepulsionWeight (double w)
Sets the weight for the energy function Repulsion. More...

void setSpeed (SpeedParameter sp)
More convenient way of setting the speed of the algorithm. More...

void setStartTemperature (int t)
Sets the starting temperature to t. 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 Attributes

double m_attractionWeight
The weight for attraction energy. More...

bool m_crossings
Should crossings be computed? More...

bool m_itAsFactor
Should m_numberOfIterations be factor (true) or fixed number. More...

double m_multiplier
By default, number of iterations per temperature step is number of vertices multiplied by multiplier. More...

double m_nodeOverlapWeight
The weight for node overlap energy. More...

int m_numberOfIterations
The number of iterations per temperature step. More...

double m_planarityWeight
The weight for edge crossing energy. More...

double m_prefEdgeLength
Preferred edge length (abs value), only used if > 0. More...

double m_repulsionWeight
The weight for repulsion energy. More...

SpeedParameter m_speed
You can override this by manually setting iter=0. More...

int m_startTemperature
The temperature at the start of the optimization. More...

## Detailed Description

The Davidson-Harel layout algorithm.

The implementation used in DavidsonHarelLayout is based on the following publication:

Ron Davidson, David Harel: Drawing Graphs Nicely Using Simulated Annealing. ACM Transactions on Graphics 15(4), pp. 301-331, 1996.

Definition at line 49 of file DavidsonHarelLayout.h.

## ◆ SettingsParameter

 strong

Easy way to set fixed costs.

Enumerator
Standard
Repulse
Planar

Definition at line 53 of file DavidsonHarelLayout.h.

## ◆ SpeedParameter

 strong

Easy way to set temperature and iterations.

Enumerator
Fast
Medium
HQ

Definition at line 56 of file DavidsonHarelLayout.h.

## ◆ DavidsonHarelLayout()

 ogdf::DavidsonHarelLayout::DavidsonHarelLayout ( )

Creates an instance of Davidson-Harel layout.

## ◆ ~DavidsonHarelLayout()

 ogdf::DavidsonHarelLayout::~DavidsonHarelLayout ( )
inline

Definition at line 61 of file DavidsonHarelLayout.h.

## ◆ call()

 virtual void ogdf::DavidsonHarelLayout::call ( GraphAttributes & GA )
overridevirtual

Calls the layout algorithm for graph attributes GA.

Implements ogdf::LayoutModule.

## ◆ fixSettings()

 void ogdf::DavidsonHarelLayout::fixSettings ( SettingsParameter sp )

Fixes the cost values to special configurations.

## ◆ getAttractionWeight()

 double ogdf::DavidsonHarelLayout::getAttractionWeight ( ) const
inline

Returns the weight for the energy function Attraction.

Definition at line 96 of file DavidsonHarelLayout.h.

## ◆ getNodeOverlapWeight()

 double ogdf::DavidsonHarelLayout::getNodeOverlapWeight ( ) const
inline

Returns the weight for the energy function NodeOverlap.

Definition at line 102 of file DavidsonHarelLayout.h.

## ◆ getNumberOfIterations()

 int ogdf::DavidsonHarelLayout::getNumberOfIterations ( ) const
inline

Returns the number of iterations per temperature step.

Definition at line 120 of file DavidsonHarelLayout.h.

## ◆ getPlanarityWeight()

 double ogdf::DavidsonHarelLayout::getPlanarityWeight ( ) const
inline

Returns the weight for the energy function Planarity.

Definition at line 108 of file DavidsonHarelLayout.h.

## ◆ getRepulsionWeight()

 double ogdf::DavidsonHarelLayout::getRepulsionWeight ( ) const
inline

Returns the weight for the energy function Repulsion.

Definition at line 90 of file DavidsonHarelLayout.h.

## ◆ getStartTemperature()

 int ogdf::DavidsonHarelLayout::getStartTemperature ( ) const
inline

Returns the starting temperature.

Definition at line 114 of file DavidsonHarelLayout.h.

## ◆ setAttractionWeight()

 void ogdf::DavidsonHarelLayout::setAttractionWeight ( double )

Sets the weight for the energy function Attraction.

## ◆ setIterationNumberAsFactor()

 void ogdf::DavidsonHarelLayout::setIterationNumberAsFactor ( bool b )
inline

Switch between using iteration number as fixed number or factor (*number of nodes of graph)

Definition at line 124 of file DavidsonHarelLayout.h.

## ◆ setNodeOverlapWeight()

 void ogdf::DavidsonHarelLayout::setNodeOverlapWeight ( double )

Sets the weight for the energy function NodeOverlap.

## ◆ setNumberOfIterations()

 void ogdf::DavidsonHarelLayout::setNumberOfIterations ( int steps )

Sets the number of iterations per temperature step to steps.

## ◆ setPlanarityWeight()

 void ogdf::DavidsonHarelLayout::setPlanarityWeight ( double )

Sets the weight for the energy function Planarity.

## ◆ setPreferredEdgeLength()

 void ogdf::DavidsonHarelLayout::setPreferredEdgeLength ( double elen )
inline

Sets the preferred edge length to elen.

Definition at line 84 of file DavidsonHarelLayout.h.

## ◆ setPreferredEdgeLengthMultiplier()

 void ogdf::DavidsonHarelLayout::setPreferredEdgeLengthMultiplier ( double multi )
inline

Sets the preferred edge length multiplier for attraction.

This is bad design, cause you dont need to have an attraction function, DH is purely modular and independent with its cost functions.

Definition at line 81 of file DavidsonHarelLayout.h.

## ◆ setRepulsionWeight()

 void ogdf::DavidsonHarelLayout::setRepulsionWeight ( double w )

Sets the weight for the energy function Repulsion.

## ◆ setSpeed()

 void ogdf::DavidsonHarelLayout::setSpeed ( SpeedParameter sp )

More convenient way of setting the speed of the algorithm.

Influences number of iterations per temperature step, starting temperature, and cooling factor.

## ◆ setStartTemperature()

 void ogdf::DavidsonHarelLayout::setStartTemperature ( int t )

Sets the starting temperature to t.

## ◆ m_attractionWeight

 double ogdf::DavidsonHarelLayout::m_attractionWeight
private

The weight for attraction energy.

Definition at line 128 of file DavidsonHarelLayout.h.

## ◆ m_crossings

 bool ogdf::DavidsonHarelLayout::m_crossings
private

Should crossings be computed?

Definition at line 136 of file DavidsonHarelLayout.h.

## ◆ m_itAsFactor

 bool ogdf::DavidsonHarelLayout::m_itAsFactor
private

Should m_numberOfIterations be factor (true) or fixed number.

Definition at line 137 of file DavidsonHarelLayout.h.

## ◆ m_multiplier

 double ogdf::DavidsonHarelLayout::m_multiplier
private

By default, number of iterations per temperature step is number of vertices multiplied by multiplier.

Definition at line 134 of file DavidsonHarelLayout.h.

## ◆ m_nodeOverlapWeight

 double ogdf::DavidsonHarelLayout::m_nodeOverlapWeight
private

The weight for node overlap energy.

Definition at line 129 of file DavidsonHarelLayout.h.

## ◆ m_numberOfIterations

 int ogdf::DavidsonHarelLayout::m_numberOfIterations
private

The number of iterations per temperature step.

Definition at line 132 of file DavidsonHarelLayout.h.

## ◆ m_planarityWeight

 double ogdf::DavidsonHarelLayout::m_planarityWeight
private

The weight for edge crossing energy.

Definition at line 130 of file DavidsonHarelLayout.h.

## ◆ m_prefEdgeLength

 double ogdf::DavidsonHarelLayout::m_prefEdgeLength
private

Preferred edge length (abs value), only used if > 0.

Definition at line 135 of file DavidsonHarelLayout.h.

## ◆ m_repulsionWeight

 double ogdf::DavidsonHarelLayout::m_repulsionWeight
private

The weight for repulsion energy.

Definition at line 127 of file DavidsonHarelLayout.h.

## ◆ m_speed

 SpeedParameter ogdf::DavidsonHarelLayout::m_speed
private

You can override this by manually setting iter=0.

Definition at line 133 of file DavidsonHarelLayout.h.

## ◆ m_startTemperature

 int ogdf::DavidsonHarelLayout::m_startTemperature
private

The temperature at the start of the optimization.

Definition at line 131 of file DavidsonHarelLayout.h.

The documentation for this class was generated from the following file: