People are talking about Genitor...
Visit Genitor Corporation Online Now!

C/C++ Sources

By Victor R. Volkman
March 1996 (No. 2)


Victor R. Volkman received a BS in Computer Science from Michigan Technological University. He has been a frequent contributor to the C/C++ Users Journal since 1987. He is the author of book Windows Programming with Shareware Tools. He can be reached at


Algorithms are abstract tools which describe a problem to be solved and how to do it. Algorithms in Computer Science texts are typically written in pseudo-code, a shorthand which conveys the structure of processing while leaving out obvious detail. Algorithms in the form of a small but easily adaptable demonstration source program or libraries are also valuable. My sweep of the WWW has produced both types of algorithms that I will share with you. Specifically, I'll point you towards algorithms for graphs, generic implementations, numerical methods, operations research, parallelism, and evolutionary computing (including genetic algorithms and neural networks).


Moving from pseudo-code to practical implementations, I turn next to "LEDA: The Library of Efficient Data Types and Algorithms" maintained by Christian Uhrig ( at the Max Planck Institute of Computer Science. LEDA is a platform-independent C++ class library that supports most compilers including Zortech, Borland, and AT&T style "cfront" C++ compilers. Specifically, LEDA supplies efficient implementations for many data types such as Fibonacci heaps for priority queues, red-black trees, dynamic perfect hashing for dictionaries and more. LEDA contains an especially useful graph implementation including:

  • Iterations such as "for al nodes do" and "for all neighbors do"
  • Add and delete vertices and edges
  • Arrays and matrices indexed by nodes and edges
  • Methods which mimic textbook pseudo-code directives

    You can obtain LEDA by FTP from, note that it is available BOTH in pkZIP and tgz (tar'red and gnuZipped) archive formats:

        Filenames                  Size
       -----------               --------
       FAQ                          19 Kb
       GMBH                          1 Kb               1124 Kb
       LEDA-R-3.2.3.tgz            717 Kb
       LEDA-R-3.3.b.tgz            791 Kb             741 Kb


    "Algorithm-Oriented Generic Libraries" ( created by alsser and Stepanov ( provides a new spin on an old subject. Their approach differentiates itself by using generic containers rather than the traditional parameterization methods of templates. By expressing the algorithms in terms of basic access operations and making the operations parameters, generic libraries permit a single expression of the algorithms to be used with any concrete representation of the container. Musser and Stepanov use C++ to demonstrate their techniques, but emphasize that other languages such as Ada are equally suited.


    A completely different branch of algorithm research and design involves numerical methods. "Teaching Numerical Analysis" ( is meant to accompany the textbook of the same name by John Mathews Mathews covers the traditional undergraduate curriculum in Numerical Analysis, including non-linear and linear equations, differentiation and integration, differential and partial-differential equations, and eigenvalues and eigenvectors. Algorithms are presented in Ryan-McFarland FORTRAN but the concepts should be transportable to C/C++ either by transcription or perhaps using the GNU f2c (Fortran-to-C) translator


    Operations Research is a business-oriented class of algorithms that are typically used to minimize costs (production) or maximize profits. You can browse a listing of packages at the "Operations Research and Mathematical Optimization - Software" page ( Most of these packages are oriented towards "Linear Programming".


    Parallel algorithms revolve around properly exploiting the resources of multiple CPU computers. The "ICASE Parallel Algorithm Highlights" page ( focuses specifically on parallelism as applied to rendering of 3-D photo-realistic images. ICASE has developed a data distributed parallel algorithm for ray-traced volume rendering, which distributes not only the data but also the rendering and image compositing process.

    They have also developed a parallel polygon rendering algorithm. These algorithms allow interactive visualization of the massive datasets for scientific applications. By exploiting the available parallelism to perform graphics operations in place, you can obtain visual feedback from an ongoing computation without moving the entire dataset across the network.

    Many problems are difficult to parallelize into equally sized pieces that can be worked on independently and without constant communication. These so-called "irregular problems" are the subject of the "Implementations of Irregular Parallel Algorithms" page ( These pages provide pseudo-code and list the pros and cons of implementations involving the following irregular problems:

  • Sorting and Merging
  • Sparse Matrix Operations
  • Connected Components
  • Scans and Linear Recurrences
  • List Ranking
  • Graph Separators
  • N-body Simulation
  • Preconditioned Conjugate Gradient


    The hottest area for algorithm research and design is the family of studies which fall under the category of Evolutionary Computation (EC). EC embraces all of the heuristic algorithm subtypes, including Genetic Algorithms, Neural Networks, Evolutionary Programming, Evolution Strategies, Classifier Systems, Genetic Programming, and Darwinian strategies lumped together as Evolutionary Algorithms. If you're new to EC concepts and definitions, you might as well start with the FAQ page (

    The "Genetic Algorithm Research Group Online Resources" page ( is a great place to begin your search for GA libraries. It also provides extensive pointers to URLs describing Artificial Life and Cellular Automata. The "MSU Genetic Algorithms Research and Applications Group (the GARAGe)" ( offers two libraries to get you started: GALOPPS and "lil-gp".

    The "Genetic ALgorithm Optimized for Portability and Parallelism System" (GALOPPS) is a generic C genetic algorithm tool that provides an enormous range of options for genetic algorithm experiments. In particular:

  • Runs on both PCs and Unix workstations (same source code))
  • Runs on a single CPU or symettric multiprocessors (SMP)
  • Supports multi-population runs with arbitrary topologies for exchanges among subpopulations.
  • Includes complete documentation and a large number of examples.
  • New DJGPP (GNU C) version can use all available RAM.
  • PVM compatible for better load balancing on SMP machines.

    lil-gp is a generic C genetic programming tool. It was written with several goals: speed, ease of use, and support for the following

  • Runs on both workstations and PCs (requires dgjpp on PC)
  • Support for multiple population experiments with arbitrary and user settable topologies for exchange.
  • Use trees of function pointers optimized for speed and avoiding swapping.
  • lil-gp now supports the use of ADFs.

    The "CMU Artificial Intelligence Repository" page ( is the home of the Genetic Algorithms and Neural Networks Library (GENlib). This repository contains a library of functions for Genetic Algorithms together with two applications of this library to train Neural Networks: "cosine" and "vartop".

    The cosine application uses a genetic algorithm to train a simple three layer Feed-Forward network to work as a cosine-function. This task is very difficult to train for a Backwards Propagation Algorithm, but the the Genetic Algorithm produces good results. The vartop applicatoin demonstrates developing a Neural Network to perform the XOR-function (a classic problem). This is done with two Genetic Algorithms, the first one develops the topology of the network, and the second one adjusts the weights.

    Both applications are written in C and have been tested and verified for the IBM PC and IBM RS/6000 platforms. These programs may be used for academic research and educational purposes only. Commercial and non-academic purposes require written permission of the author.


    Neural networks are pattern recognition algorithms that learn by example.

    The DYSTAL Algorithm page describes the culmination of an 8 year research project a neural network based on biological associative learning with non-Hebbian learning rules. The Dynamically STable Associative Learning (DYSTAL) algorithm is based on the biophysics and electrophysiology of the changes that learning produces in a "patch" of dendritic membrane (cluster of synapses) of individual neurons.

    DYSTAL, like biological associative learning, works by learning an association between two inputs, called the Conditioned Stimulus (CS) and the Unconditioned Stimulus (UCS), to conform with the usage in the associative learning literature. Recall that Pavlov's dogs learned to associate the sound of a bell (the CS) with the smell of meat (the UCS), so they salivated when they heard the bell alone. Humans (and DYSTAL) have generalized this ability to associate events consistently presented in the same sequence, so that any repeatedly paired stimuli can be associated.


    "Visual Programming: The Best of Internet" by Pacific HiTech provides 163 MB (unzipped) of libraries for use with Microsoft Visual Basic, Visual C/C++, Borland C++, and other compatible environments. In all, some 250 different products are represented. Approximately 90% of the products presented are VBXs designed for use with VB, though they can of course be called from other environments.

    I've done considerable research in this area for my book Windows Programming with Shareware Tools and was pleasantly surprised to find many new products here that were new to me. I recommend this disk mainly for Visual Basic users. It would require you dozens of hours to acquire this software over the Internet yourself.

    The HiTech browser provides the main method of locating products of interest. You can browse by category or perform text searches against descriptions, authors, and platform (see Fig. 2). My only complaint with the browser itself was that I had difficulty reading some of the fonts in 640x480.

    I found the quality of the long descriptions to be uneven. Some descriptions had as many as five exclamation points (!), a few typos, and many others referred to figures or lists that were plainly missing. Nevertheless, the descriptions do give you some idea of what each product is about.

    Product:    Visual Programming CD-ROM, $30
    Release:    Sept. 1995 Edition
    Vendor:     Pacific HiTech
                3855 South 500 W. Suite B
                Salt Lake City, UT 84115
    ASP Member: No
    Phone:      (800)765-8369
    Email: or

    [Up] [Prev Doc] [Next Doc]
    This page maintained by Victor R. Volkman
    Last updated on 07/04/99 (Happy 4th of July)