Tulip  5.7.4
Large graphs analysis and drawing
tlp::Algorithm Class Referenceabstract

#include <Algorithm.h>

+ Inheritance diagram for tlp::Algorithm:
+ Collaboration diagram for tlp::Algorithm:

Public Member Functions

 Algorithm (const PluginContext *context)
 
std::string category () const override
 
virtual bool check (std::string &)
 
std::string icon () const override
 
virtual bool run ()=0
 
- Public Member Functions inherited from tlp::Plugin
virtual std::string author () const =0
 
virtual std::string date () const =0
 
void declareDeprecatedName (const std::string &oldName)
 
std::string deprecatedName ()
 
virtual std::string group () const =0
 
virtual int id () const
 
virtual std::string info () const =0
 
virtual std::string major () const
 
virtual std::string minor () const
 
virtual std::string name () const =0
 
virtual std::string programmingLanguage () const
 
virtual std::string release () const =0
 
virtual std::string tulipMajor () const
 
virtual std::string tulipMinor () const
 
virtual std::string tulipRelease () const =0
 

Public Attributes

DataSetdataSet
 
Graphgraph
 
PluginProgresspluginProgress
 

Additional Inherited Members

- Protected Attributes inherited from tlp::Plugin
std::string oldName
 

Detailed Description

This abstract class describes a basic algorithm plugin.

It inherits on WithParameter and WithDependency for convenience. Basic functionality consists in checking the algorithm can run on the current Graph (e.g. is the graph simple ?), running the algorithm and resetting the algorithm to re-apply it. The algorithm can and should report progress and which task it is performing if it is decomposed in multiple phases (e.g. layouting the graph, coloring it, ...).

Definition at line 46 of file Algorithm.h.

Constructor & Destructor Documentation

◆ Algorithm()

tlp::Algorithm::Algorithm ( const PluginContext context)
inline

Constructs an algorithm and initializes members from the AlgorithmContext.

Parameters
contextThe context this algorithm runs in, containing the graph, a DataSet for the parameters, and a PluginProgress to give feedback to the user about the tasks the algorithm is performing.

Definition at line 55 of file Algorithm.h.

Member Function Documentation

◆ category()

std::string tlp::Algorithm::category ( ) const
inlineoverridevirtual

A string identifier for a plugin used for categorization purposes.

Returns
std::string the category of the plugin.

Implements tlp::Plugin.

Reimplemented in tlp::StringAlgorithm, tlp::SizeAlgorithm, tlp::LayoutAlgorithm, tlp::IntegerAlgorithm, tlp::DoubleAlgorithm, tlp::ColorAlgorithm, tlp::BooleanAlgorithm, and tlp::PropertyAlgorithm.

Definition at line 80 of file Algorithm.h.

◆ check()

virtual bool tlp::Algorithm::check ( std::string &  )
inlinevirtual

Checks whether the algorithm can be applied on this graph or not. If not, the reason why should be reported through the PluginProgress.

Parameters
errorMessageA string whose value will be modified to an error message, if the check fails.
Returns
bool Whether the plug-in can run on this Graph.

Definition at line 91 of file Algorithm.h.

◆ icon()

std::string tlp::Algorithm::icon ( ) const
inlineoverridevirtual

The icon (preferably a thumbnail) of the plugin.

Returns
std::string the icon path

Reimplemented from tlp::Plugin.

Definition at line 66 of file Algorithm.h.

◆ run()

virtual bool tlp::Algorithm::run ( )
pure virtual

Runs the algorithm. It is a good practice to report progress through the PluginProgress, Even if your algorithm is very fast. Keep in mind that Tulip can handle very large graphs. The PluginProgress should also be used to report errors, if any.

Returns
bool Whether the algorithm execution was successful or not.

Member Data Documentation

◆ dataSet

DataSet* tlp::Algorithm::dataSet

A DataSet containing parameters for this algorithm, if any. Retrieved from the context at construction.

Definition at line 107 of file Algorithm.h.

◆ graph

Graph* tlp::Algorithm::graph

The graph this algorithm will be run on. Retrieved from the context at construction.

Definition at line 97 of file Algorithm.h.

◆ pluginProgress

PluginProgress* tlp::Algorithm::pluginProgress

A PluginProgress to give feedback to the user, retrieved from the context. It can be a nullptr pointer, so use with caution.

Definition at line 102 of file Algorithm.h.