next up previous
Next: 2.2 Compiling Up: 2.1 Design Previous: 2.1.2 Data structures

2.1.3 Adding a new algorithm

The following steps show how to add a clustering algorithm called foo to the cluster program.

  1. Create a pair of files cluster_foo.cc and cluster_foo.hh.
  2. In cluster_foo.hh, #include "cluster.hh" and provide a function prototype extern void cluster_foo(int k);, as is done in the various existing cluster_*.hh files.
  3. In cluster_foo.cc, #include "cluster_foo.hh", and then put the clustering algorithm into a function void cluster_foo(int k). All other functions and data should be marked as static.
  4. In Makefile, add cluster_foo.o to the end of the ``cluster: ...'' line.
  5. In Makefile, add cluster_foo.hh to the end of the ``algorithms.o: ...'' line.
  6. In Makefile, add the line ``cluster_foo.o: cluster.hh''.
  7. In algorithms.cc, #include "cluster_foo.hh" and then add to the end of the registerAlgorithms() function
    ``algorithms.insert("foo", cluster_foo);''.



Kevin Pulo
2000-08-23