The library is an attempt to bring together a set of reusable components for use in combinatorial computing. It consists of a set of data types and algorithms, with several implementations of most of the standard textbook data structures, and a set of two dimensional graphing and geometry types and algorithms.
The library provides stacks, queues, sets, sequences and other structured data types, and algorithms for graph and network theory, and 2D geometry. The class hierarchy is relatively flat, and appears easy to extend - for example, additional implementations of dictionaries can be easily added to the dictionary templates.
Parameterised containers are implemented with templates, and are used by the geometry algorithms/classes. For example
returns the points on the circle that are intersected by the line segment.list<point> c.intersection(segment s)
The library provides the following classes (taken from the contents page of the LEDA manual[18]):
A simple list of classes just not do justice to LEDA, as it also provideds a sizable collection of different implementations of the containers, and also implementations of many algorithms.
For example:
#include <LEDA/_d_array.h>
#include <LEDA/impl/ch_hash.h>
// define a (naive) hash function for strings
int Hash(const string& x) {return (x.length()>0)? x[o] : 0;}
main()
{
_d_array<string,int,ch_hash> N9o);
string s;
while (cin >> s) N[s]++;
forall_defined(s,N) cout << s << " " << N[s] << endl;
}
uses a dictionary array implemented by hashing with chaining (
ch_hash) to count the number of occurences of the elements in a
sequence of strings. This example also suffers from a problem with
cfront based compilers - implementation parameters ( ch_hash)
cannot be used. For cfront based compilers only the default
(d_array<string,int>) implementations can be used.
In addition to the many different implementations of the containers provided, several algorithms are included for the graph and network types.
Note that there are no special facilities for persistence, or for garbage collection/memory management, other than a pooled block allocation system used internally.
Error handling is either via an internal handler, that usually results in the termination of the program, or via a user supplied error handler.
stacks, queues, lists, sets, dictionaries, ordered sequences, partitions, priority queues, directed, undirected, and planar graphs, lines, points, planes and basic algorithms in graph and network theory and 2D computational geometry.
Many of the containers are particularly flexible, being parameterised on implementation - ex. dictionaries implemented with skip lists, AVL trees, dynamic perfect hashing etc.
The documentation is concise, readable, and the containers and algorithms are well specified. Short examples are given in the manual, and larger example programs supplied.
Although data types for geometry are provided, they are restricted to 2 dimensions only.