Coding Standards for Algorithms

Implementation

Algorithms in Graphlet should use Graphlet's and GTL's data stuctures. Using other data structures, such as home grown graph classes, is highly depreciated. If you feel that a specialized data structure is neccessary because of performance problems, contact the author of this document first.

Changing the Graph

Algorithms should only make changes in the graph if it is the purpose of the algorithm to do so. Here, changes include changing attributes and changing the topological structure. There is no other reason. Bear in mind that creating or deleting nodes and/or edges is quite costly in Graphlet, and destroys the structure of the graph.

For example, the insertion and deletion of dummy edges may cause a lot of activity, such as updating the display of the number of edges in the editor window. A user may have even attached additional procedures to insert/delete operations, for example to update application specific data structure (see the section on hools in the Graphscript manual for details).

Time Consuming Algorithms

Time consuming algorithms (such as spring embedder layout algorithms, or algorithms that sove NP complete problems) should do the following:

Layout Algorithms

Layout algorithms should only modify coordinates of nodes and edges. Coordinates are

  1. Node x, y coordinates
  2. Edge coordinates
  3. Node and edge anchors

Layout algorithms must never change other attributes such as labels, colors, ports or node width/height. An exception would be algorithm animation, provided there is a way to undo all the changes.

Furthermore, layout algorithms may never change the structure of a graph. That is, they may not insert or delete edges, even temporary. In fact, layout algorithms may only change coordinates and anchors.

Graph Theory Algorithms

Algorithms that test graph properties such as connectivity or planarity must not change the graph in any way. This includes temporary changes such as dummy nodes.

Algorithms which modify a graph should provide a menu entry which indicates that the graph is changed, such as "Remove excessive edges ..." or "Make graph nonplanar". They should also ask the user for confirmation.

Algorithm Animation

Algorithm animation should always provide to restore the original settings of the graph, such as colors or labels after the animation has ended. Also, the animation should change as few attributes as possible.

Algorithm animation should never be activated by default.


Graphlet | Coding Standards