# OpenGraph DrawingFramework

v.2012.07

ogdf::Attraction Class Reference

Energy function for attraction between two adjacent vertices. More...

#include <ogdf/internal/energybased/Attraction.h>

Inheritance diagram for ogdf::Attraction:

List of all members.

## Public Member Functions

Attraction (GraphAttributes &AG)
~Attraction ()
void reinitializeEdgeLength (double multi)
set multiplier for the edge length with repspect to node size to multi
void setPreferredEdgelength (double l)
set the preferred edge length to the absolute value l
Public Member Functions inherited from ogdf::NodePairEnergy
NodePairEnergy (const String energyname, GraphAttributes &AG)
virtual ~NodePairEnergy ()
void computeEnergy ()
computes energy for the layout at the beginning of the optimization process
Public Member Functions inherited from ogdf::EnergyFunction
EnergyFunction (const String &funcname, GraphAttributes &AG)
Initializes data dtructures to speed up later computations.
virtual ~EnergyFunction ()
void candidateTaken ()
Changes m_currentX and m_currentY by setting the position of m_testNode to m_testX and m_testY. Sets m_energy to m_candidateEnergy. Computes the energy of the layout stored in AG.
double computeCandidateEnergy (const node v, const DPoint &newPos)
sets m_testNode, m_testX and m_testY and computes the energy for the new configuration (vertex v moves to newPos)
double energy () const
String getName () const
prints the name of the energy function

## Private Member Functions

double computeCoordEnergy (node, node, const DPoint &, const DPoint &) const
computes the energy contributed by the two nodes if they are placed at the two given positions

## Private Attributes

double m_preferredEdgeLength
the length that that all edges should ideally have

## Static Private Attributes

static const double MULTIPLIER
Average length and height of nodes is multiplied by this factor to get preferred edge length.

Protected Member Functions inherited from ogdf::NodePairEnergy
bool adjacent (const node v, const node w) const
int nodeNum (node v) const
const IntersectionRectangleshape (const node v) const
Protected Member Functions inherited from ogdf::EnergyFunction
DPoint currentPos (const node v) const
returns the current position of vertex v
node testNode () const
returns the vertex that is under consideration in the current step
DPoint testPos ()
returns candidate position for the node to be moved

## Detailed Description

Energy function for attraction between two adjacent vertices.

Implements an energy function that simulates attraction between two adjacent vertices. There is an optimum distance where the energy is zero. The energy grows quadratic with the difference to the optimum distance. The optimum distance between two adjacent vertices depends on the size of the two vertices.

Definition at line 66 of file Attraction.h.

## Constructor & Destructor Documentation

 ogdf::Attraction::Attraction ( GraphAttributes & AG )
 ogdf::Attraction::~Attraction ( )
inline

Definition at line 70 of file Attraction.h.

## Member Function Documentation

 double ogdf::Attraction::computeCoordEnergy ( node , node , const DPoint & , const DPoint & ) const
privatevirtual

computes the energy contributed by the two nodes if they are placed at the two given positions

Implements ogdf::NodePairEnergy.

 void ogdf::Attraction::reinitializeEdgeLength ( double multi )

set multiplier for the edge length with repspect to node size to multi

 void ogdf::Attraction::setPreferredEdgelength ( double l )
inline

set the preferred edge length to the absolute value l

Definition at line 72 of file Attraction.h.

## Member Data Documentation

 double ogdf::Attraction::m_preferredEdgeLength
private

the length that that all edges should ideally have

Definition at line 82 of file Attraction.h.

 const double ogdf::Attraction::MULTIPLIER
staticprivate

Average length and height of nodes is multiplied by this factor to get preferred edge length.

Definition at line 80 of file Attraction.h.

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