Reference documentation
Public Member Functions | List of all members
GraphAlgorithm Class Reference

The Thistle::GraphAlgorithm class provides a default algorithm to calculate the positions of the nodes in a Thistle::GraphView. More...

Inheritance diagram for GraphAlgorithm:
AbstractGraphAlgorithm

Public Member Functions

void run ()
 The function is pure virtual. More...
 
- Public Member Functions inherited from AbstractGraphAlgorithm
 AbstractGraphAlgorithm (GraphView *parent)
 Initializes the abstract object with the given parent.
 
 ~AbstractGraphAlgorithm ()
 Destructs the current instance.
 
const Node node (const QModelIndex &index) const
 Returns the Thistle::Node corresponding to the given index.
 
void setPosition (const QModelIndex &index, QPointF pos)
 Sets the position pos to the given index. More...
 

Detailed Description

The Thistle::GraphAlgorithm class provides a default algorithm to calculate the positions of the nodes in a Thistle::GraphView.

The Thistle::GraphAlgorithm class provides a default algorithm to calculate the positions of the nodes in a Thistle::GraphView.

This class implements the elastic effect that pulls and pushes on nodes. this is a very simple and efficient algorihtm.

First, we calculate the forces that push the nodes apart. Then, we subtract the forces that pull the nodes together. this algorithm takes a certain time to calculate the forces and find the final position of each item. So, we can see the nodes moving on the view.

If you want to implement you own algorithm, use the Thistle::AbstractGraphAlgorithm abstract class as base.

Member Function Documentation

void run ( )
virtual

The function is pure virtual.

this function is used to calculate the position of Thistle::Node in a Thistle::GraphView. Implement this function to use your own algorithm.

Implements AbstractGraphAlgorithm.