search.cpan.org is shutting down
For details read Perl NOC. After June 25th this page will redirect to MetaCPAN.org
Petr Baudis > Graph-Layderer > Graph::Layouter::Spring

Graph-Layderer-0.03.tar.gz

Dependencies

Annotate this POD

# CPAN RT

 Open 2
View/Report Bugs
Module Version: 0.03

# NAME

Graph::Layouter::Spring - spring graph drawing algorithm implementation

# SYNOPSIS

```  use Graph::Layouter::Spring;
Graph::Layouter::Spring::layout(\$graph);```

# DESCRIPTION

This module provides the famous spring graph drawing algorithm implementation. See the `Graph::Layouter` class documentation for usage description.

## How does it work

The algorithm is principially simple, simulating a space of electrically charged particles. Basically, each node is thought of as a particle with the same charge, therefore they all try to get as far of each other as possible. On the other hand, though, there are the edges, which keep nodes together; higher weight the edges have, stronger are they in pulling nodes near each other.

So to recapitulate, we have repulsive force pushing nodes from each other and attractive force pushing connected nodes near each other. We then just apply the repulsive force between each two nodes and the attractive force between each two connected nodes; each node will have a resulting movement force, which we will apply to the node's position (initially randomzero-zero) after the forces calculation is finished.

However, we need to let this repeat for several times in order for the positions to stabilize. In fact, a lot of iterations is needed; higher the better, but also higher the slower, you can very easily get to tens of seconds here so beware. Currently, the number of iterations is hardcoded to 500, but this is expected to get configurable soon.

`Graph`, `Graph::Layouter`, `Graph::Renderer`

# BUGS

The object-oriented interface is missing as well as some more universal layout calling interface (hash parameters).

It should all be configurable.