--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/8a14b4849071f910 Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,9 @@
+From artemis Thu Jan 10 09:43:00 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Thu, 10 Jan 2008 04:36:03 -0500
+State: new
+Subject: Remove maintenance of "lazy decomposition"
+Message-Id: <8a14b4849071f910-0-artemis@metatron>
+
+The maintenance of "lazy decomposition" (added in [a0736dd3c671]) is
+incorrect (due to original theoretical errors). Remove it completely.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/91986229a564f7e0 Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,19 @@
+From artemis Thu Feb 21 09:24:11 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Thu, 21 Feb 2008 04:23:29 -0500
+State: fixed
+Subject: More elabroate domain in avida-landscape
+Message-Id: <91986229a564f7e0-0-artemis@metatron>
+
+Try minimum spanning tree (i.e., take only negative edges from avida-distance).
+Try a combination: all edges up to a certain (realtively small) length + MST.
+
+From artemis Mon Feb 25 12:09:30 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Mon, 25 Feb 2008 07:09:30 -0500
+Subject: properties changes (state)
+Message-Id: <91986229a564f7e0-9886ad2e18d12feb-artemis@metatron>
+References: <91986229a564f7e0-0-artemis@metatron>
+In-Reply-To: <91986229a564f7e0-0-artemis@metatron>
+
+state=fixed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/e6d9deee8fbd81a5 Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,8 @@
+From artemis Wed Feb 6 21:45:35 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Wed, 06 Feb 2008 16:45:13 -0500
+State: new
+Subject: About section in README
+Message-Id: <e6d9deee8fbd81a5-0-artemis@metatron>
+
+Add "About" section to the README file.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/e8659770a6824e01 Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,11 @@
+From artemis Wed Jan 9 18:59:35 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Wed, 09 Jan 2008 13:57:57 -0500
+State: new
+Subject: Change cout to rlog
+Message-Id: <e8659770a6824e01-0-artemis@metatron>
+
+In examples/grid/grid2Dvineyard.hpp (and in examples in general),
+change the use of std::cout for logging information to rlog.
+Naturally, create appropriate channels even if they are of only local
+use.
--- a/examples/CMakeLists.txt Wed Feb 27 07:56:26 2008 -0500
+++ b/examples/CMakeLists.txt Wed Feb 27 07:57:45 2008 -0500
@@ -1,5 +1,6 @@
add_subdirectory (alphashapes)
add_subdirectory (ar-vineyard)
add_subdirectory (cech-complex)
+add_subdirectory (fitness)
add_subdirectory (grid)
add_subdirectory (triangle)
--- a/examples/cech-complex/cech-complex.cpp Wed Feb 27 07:56:26 2008 -0500
+++ b/examples/cech-complex/cech-complex.cpp Wed Feb 27 07:57:45 2008 -0500
@@ -14,18 +14,7 @@
typedef SimplexWithValue<PointIndex> Simplex;
typedef std::vector<Simplex> SimplexVector;
typedef Filtration<Simplex> CechFiltration;
-
-class DimensionValueComparison
-{
- public:
- bool operator()(const Simplex& s1, const Simplex& s2) const
- {
- if (s1.dimension() == s2.dimension())
- return s1.get_value() < s2.get_value();
- else
- return s1.dimension() < s2.dimension();
- }
-};
+typedef DimensionValueComparison<Simplex> DimValComparison;
int choose(int n, int k)
{
@@ -109,7 +98,7 @@
add_simplices(sv, i, points);
std::cout << "Size of SimplexVector: " << sv.size() << std::endl;
- std::sort(sv.begin(), sv.end(), DimensionValueComparison());
+ std::sort(sv.begin(), sv.end(), DimValComparison());
for (SimplexVector::const_iterator cur = sv.begin(); cur != sv.end(); ++cur)
cf.append(*cur);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/fitness/CMakeLists.txt Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,11 @@
+set (targets
+ avida-distance
+ avida-landscape)
+
+find_library (boost_program_options_LIBRARY NAME boost_program_options
+ PATHS ${Boost_LIBRARY_DIR})
+
+foreach (t ${targets})
+ add_executable (${t} ${t}.cpp)
+ target_link_libraries (${t} ${libraries} ${boost_program_options_LIBRARY})
+endforeach (t ${targets})
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/fitness/avida-distance.cpp Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,94 @@
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "avida-population-detail.h"
+
+#include <topology/filtration.h>
+#include <topology/simplex.h>
+
+
+typedef SimplexWithValue<AvidaOrganismDetail::IDType> Simplex;
+typedef std::vector<Simplex> SimplexVector;
+typedef Filtration<Simplex> SimplexFiltration;
+
+int main(int argc, char** argv)
+{
+#ifdef LOGGING
+ rlog::RLogInit(argc, argv);
+ //stdoutLog.subscribeTo(RLOG_CHANNEL("info"));
+#endif
+
+ if (argc < 2)
+ {
+ std::cout << "USAGE: avida FILENAME" << std::endl;
+ return 0;
+ }
+
+ AvidaPopulationDetail population(argv[1]);
+ const AvidaPopulationDetail::OrganismVector& organisms = population.get_organisms();
+
+ rInfo("Number of organisms: %d", organisms.size());
+ for (int i = 0; i < population.get_organisms().size(); ++i)
+ rInfo("%d (%s) %f %d %d", organisms[i].id(),
+ organisms[i].genome().c_str(),
+ organisms[i].fitness(),
+ organisms[i].length(),
+ organisms[i].genome().size());
+
+ // Distance function filtration
+ SimplexVector simplices;
+
+ // Insert edges
+ AvidaOrganismDetail::DistanceType avg_distance = 0;
+ for (AvidaOrganismDetail::CountType i = 0; i < organisms.size(); ++i)
+ {
+ simplices.push_back(0);
+ simplices.back().add(organisms[i].id());
+
+ for (AvidaOrganismDetail::CountType j = i+1; j < organisms.size(); ++j)
+ {
+ avg_distance += organisms[i].genome_distance(organisms[j]);
+ simplices.push_back(Simplex(organisms[i].genome_distance(organisms[j])));
+ simplices.back().add(organisms[i].id());
+ simplices.back().add(organisms[j].id());
+ }
+ }
+ std::sort(simplices.begin(), simplices.end(), DimensionValueComparison<Simplex>());
+ rInfo("Average distance: %f", float(avg_distance)/
+ ((organisms.size()*organisms.size() - organisms.size())/2));
+
+ SimplexFiltration filtration;
+ for (SimplexVector::const_iterator cur = simplices.begin(); cur != simplices.end(); ++cur)
+ {
+ rInfo("Simplex: %s", tostring(*cur).c_str());
+ filtration.append(*cur);
+ }
+
+ filtration.fill_simplex_index_map();
+ filtration.pair_simplices(false); // pair simplices without storing trails
+
+ std::cout << "Outputting histogram of death values" << std::endl;
+ typedef std::vector<RealType> DeathVector;
+ DeathVector deaths;
+ for (SimplexFiltration::Index i = filtration.begin(); i != filtration.end(); ++i)
+ {
+ if (i->is_paired())
+ if (i->sign())
+ {
+ AssertMsg(i->dimension() == 0, "Expecting only 0-dimensional diagram");
+ AssertMsg(i->get_value() == 0, "Expecting only 0 birth values in 0-D diagram ");
+ deaths.push_back(i->pair()->get_value());
+ }
+ }
+
+ // Produce histogram
+ std::sort(deaths.begin(), deaths.end());
+ for (DeathVector::iterator cur = deaths.begin(); cur != deaths.end(); )
+ {
+ DeathVector::iterator nw = std::find_if(cur, deaths.end(),
+ std::bind2nd(std::greater<RealType>(), *cur));
+ std::cout << *cur << "\t" << (nw - cur) << std::endl;
+ cur = nw;
+ }
+ std::cout << "Total: " << deaths.size() + 1; // +1 for the unpaired
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/fitness/avida-landscape.cpp Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,196 @@
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include <string>
+#include "avida-population-detail.h"
+
+#include <boost/program_options.hpp>
+
+#include <topology/lowerstarfiltration.h>
+
+
+// Lower-star filtration
+typedef AvidaPopulationDetail::OrganismIndex OrganismIndex;
+struct OrganismVertexType;
+typedef std::vector<OrganismVertexType> VertexVector;
+typedef VertexVector::iterator VertexIndex;
+typedef LowerStarFiltration<VertexIndex> LSFiltration;
+typedef LSFiltration::Simplex Simplex;
+
+struct OrganismVertexType: public LSFiltration::VertexType<OrganismIndex>
+{
+ typedef LSFiltration::VertexType<OrganismIndex> Parent;
+ OrganismVertexType(OrganismIndex i): Parent(i) {}
+};
+
+struct OrganismVertexComparison
+{
+ public:
+ bool operator()(VertexIndex i, VertexIndex j) const
+ { return i->index()->fitness() > j->index()->fitness(); }
+ // > because of -fitness, so that maxima turn into minima
+};
+
+typedef LSFiltration::Vineyard LSVineyard;
+class StaticEvaluator: public LSVineyard::Evaluator
+{
+ public:
+ virtual RealType
+ value(const Simplex& s) const
+ { return s.get_attachment()->index()->fitness(); }
+};
+
+std::ostream& operator<<(std::ostream& out, VertexIndex i)
+{ return (out << (i->index())); }
+
+
+// Distance filtration
+typedef SimplexWithValue<VertexIndex> DistanceSimplex;
+typedef std::vector<DistanceSimplex> DistanceSimplexVector;
+typedef Filtration<DistanceSimplex> DistanceSimplexFiltration;
+
+
+namespace po = boost::program_options;
+
+int main(int argc, char** argv)
+{
+#ifdef LOGGING
+ rlog::RLogInit(argc, argv);
+ stderrLog.subscribeTo(RLOG_CHANNEL("error"));
+ //stdoutLog.subscribeTo(RLOG_CHANNEL("info"));
+#endif
+
+ typedef AvidaOrganismDetail::DistanceType DistanceType;
+
+ DistanceType connected_distance;
+ bool connect_mst = false;
+ std::string population_input_fn;
+
+ // Parse program options
+ po::options_description hidden("Hidden options");
+ hidden.add_options()
+ ("input-file", po::value<std::string>(&population_input_fn),
+ "Avida population file");
+
+ po::options_description visible("Allowed options");
+ visible.add_options()
+ ("help,h", "produce help message")
+ ("distance,d", po::value<DistanceType>(&connected_distance)->default_value(0),
+ "set connected distance")
+ ("mst,m", "connect minimum spanning tree");
+ po::positional_options_description p;
+ p.add("input-file", 1);
+
+ po::options_description all; all.add(visible).add(hidden);
+
+ po::variables_map vm;
+ po::store(po::command_line_parser(argc, argv).
+ options(all).positional(p).run(), vm);
+ po::notify(vm);
+
+ if (vm.count("mst")) { connect_mst = true; }
+ if (vm.count("help") || !vm.count("input-file"))
+ {
+ std::cout << "Usage: " << argv[0] << " [options] POPULATION" << std::endl;
+ std::cout << visible << std::endl;
+ return 1;
+ }
+
+ // Read organisms
+ AvidaPopulationDetail population(population_input_fn);
+ const AvidaPopulationDetail::OrganismVector& organisms = population.get_organisms();
+
+ rInfo("Number of organisms: %d", organisms.size());
+ for (int i = 0; i < population.get_organisms().size(); ++i)
+ rInfo("%d (%s) %f %d %d", organisms[i].id(),
+ organisms[i].genome().c_str(),
+ organisms[i].fitness(),
+ organisms[i].length(),
+ organisms[i].genome().size());
+
+ // Order vertices
+ StaticEvaluator evaluator;
+ LSVineyard vineyard(&evaluator);
+ VertexVector vertices;
+ for (OrganismIndex cur = organisms.begin(); cur != organisms.end(); ++cur) vertices.push_back(cur);
+ LSFiltration fitness_filtration(vertices.begin(), vertices.end(), OrganismVertexComparison(), &vineyard);
+
+ // Compute MST and insert its edges if asked
+ if (connect_mst)
+ {
+ DistanceSimplexFiltration filtration;
+ { // Scope so that simplices is deleted once it's not needed
+ // Distance function filtration
+ DistanceSimplexVector simplices;
+
+ // Insert edges
+ for (VertexIndex i = vertices.begin(); i != vertices.end(); ++i)
+ {
+ simplices.push_back(DistanceSimplex());
+ simplices.back().add(i);
+
+ for (VertexIndex j = boost::next(i); j != vertices.end(); ++j)
+ {
+ simplices.push_back(DistanceSimplex(i->index()->genome_distance(*(j->index()))));
+ simplices.back().add(i);
+ simplices.back().add(j);
+ }
+ }
+ std::sort(simplices.begin(), simplices.end(), DimensionValueComparison<DistanceSimplex>());
+
+ for (DistanceSimplexVector::const_iterator cur = simplices.begin();
+ cur != simplices.end(); ++cur)
+ filtration.append(*cur);
+ }
+
+ filtration.fill_simplex_index_map();
+ filtration.pair_simplices(false); // pair simplices without storing trails
+
+ for (DistanceSimplexFiltration::Index i = filtration.begin(); i != filtration.end(); ++i)
+ {
+ if (i->is_paired() && !i->sign())
+ {
+ Simplex s(*i);
+ if (i->get_value() > connected_distance) // <= will be connected below
+ fitness_filtration.append(s);
+ }
+ }
+ }
+
+ // Add simplices
+ for (VertexIndex cur = vertices.begin(); cur != vertices.end(); ++cur)
+ for (VertexIndex link = boost::next(cur); link != vertices.end(); ++link)
+ if (cur->index()->genome_distance(*(link->index())) <= connected_distance)
+ {
+ Simplex s(2, cur); s.add(link);
+ fitness_filtration.append(s);
+ }
+ rInfo("Number of simplices: %d", fitness_filtration.size());
+
+ // Pair simplices
+ fitness_filtration.fill_simplex_index_map();
+ fitness_filtration.pair_simplices(false); // pair simplices without storing trails
+
+ //std::cout << "Outputting persistence pairs" << std::endl;
+ for (LSFiltration::Index i = fitness_filtration.begin(); i != fitness_filtration.end(); ++i)
+ {
+ if (i->is_paired())
+ {
+ if (i->sign())
+ {
+ AssertMsg(i->dimension() == 0, "Expecting only 0-dimensional diagram");
+ if (i->pair()->get_attachment() == i->vertices()[0]) continue; // skip non-critical pairs
+ std::cout << i->dimension() << " "
+ << evaluator.value(*i) << " "
+ << evaluator.value(*(i->pair())) << std::endl;
+ }
+ }
+ else
+ {
+ if (i->dimension() != 0) continue;
+ std::cout << i->dimension() << " "
+ << evaluator.value(*i) << " "
+ << "unpaired" << std::endl;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/fitness/avida-population-detail.h Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,68 @@
+/**
+ * Author: Dmitriy Morozov
+ * Department of Computer Science, Duke University, 2007
+ */
+
+#ifndef __AVIDA_POPULATION_DETAIL_H__
+#define __AVIDA_POPULATION_DETAIL_H__
+
+#include <string>
+#include <vector>
+
+/**
+ * Stores organism details stored in a single line of a population detail file in data/
+ * directory of Avida's output.
+ */
+class AvidaOrganismDetail
+{
+ public:
+ typedef int IDType;
+ /// Distance between two genomes
+ typedef unsigned int DistanceType;
+ typedef unsigned int CountType;
+
+ AvidaOrganismDetail(std::string line);
+
+ DistanceType genome_distance(const AvidaOrganismDetail& other) const;
+
+ IDType id() const { return id_; }
+ float fitness() const { return fitness_; }
+ CountType length() const { return genome_length_; }
+ std::string genome() const { return genome_; }
+
+ private:
+ IDType id_, parent_id_;
+ int parent_distance_;
+ CountType num_organisms_alive_, num_organisms_ever_;
+ CountType genome_length_;
+ float merit_, gestation_time_;
+ float fitness_;
+ int update_born_, update_deactivated_, depth_phylogenetic_tree_;
+ std::string genome_;
+};
+
+/**
+ * Stores entire population details (all organisms in a given time step), i.e., stores
+ * an entire population detail file in data/ directory of Avida's ouptut.
+ */
+class AvidaPopulationDetail
+{
+ public:
+ typedef std::vector<AvidaOrganismDetail> OrganismVector;
+ typedef OrganismVector::const_iterator OrganismIndex;
+
+ AvidaPopulationDetail(std::string filename);
+
+ const OrganismVector& get_organisms() const { return organisms_; }
+
+ private:
+ OrganismVector organisms_;
+};
+
+std::ostream& operator<<(std::ostream& out, AvidaPopulationDetail::OrganismIndex i)
+{ return (out << (i->id())); }
+
+
+#include "avida-population-detail.hpp"
+
+#endif //__AVIDA_POPULATION_DETAIL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/fitness/avida-population-detail.hpp Wed Feb 27 07:57:45 2008 -0500
@@ -0,0 +1,57 @@
+#include <fstream>
+#include <sstream>
+#include "utilities/log.h"
+
+/** AvidaOrganismDetail */
+
+AvidaOrganismDetail::
+AvidaOrganismDetail(std::string line)
+{
+ std::stringstream linestream(line);
+ linestream >> id_ >> parent_id_ >> parent_distance_;
+ linestream >> num_organisms_alive_ >> num_organisms_ever_;
+ linestream >> genome_length_;
+ linestream >> merit_ >> gestation_time_;
+ linestream >> fitness_;
+ linestream >> update_born_ >> update_deactivated_ >> depth_phylogenetic_tree_;
+ linestream >> genome_;
+
+ AssertMsg(genome_length_ == genome_.size(), "Genome must be of given length");
+}
+
+AvidaOrganismDetail::DistanceType
+AvidaOrganismDetail::
+genome_distance(const AvidaOrganismDetail& other) const
+{
+ AssertMsg(genome_.size() == other.genome_.size(), "Currently genome sizes must be the same for distance computation");
+ AssertMsg(genome_length_ == genome_.size(), "Genome length value must match the length of the genome string");
+ AssertMsg(other.genome_length_ == other.genome_.size(), "Genome length value must match the length of the genome string");
+
+ CountType count = 0;
+ for (CountType i = 0; i < genome_.size(); ++i)
+ if (genome_[i] != other.genome_[i])
+ ++count;
+
+ return count;
+}
+
+
+/** AvidaPopulationDetail */
+AvidaPopulationDetail::
+AvidaPopulationDetail(std::string filename)
+{
+ std::ifstream infile(filename.c_str());
+ while(infile)
+ {
+ std::string line;
+ std::getline(infile, line);
+
+ // Skip comments and empty lines
+ char c = '#';
+ std::istringstream linestream(line);
+ linestream >> c;
+ if (c == '#') continue;
+
+ organisms_.push_back(AvidaOrganismDetail(line));
+ }
+}
--- a/examples/grid/grid2Dvineyard.h Wed Feb 27 07:56:26 2008 -0500
+++ b/examples/grid/grid2Dvineyard.h Wed Feb 27 07:57:45 2008 -0500
@@ -1,6 +1,6 @@
/*
* Author: Dmitriy Morozov
- * Department of Computer Science, Duke University, 2005 -- 2006
+ * Department of Computer Science, Duke University, 2005 -- 2008
*/
#ifndef __GRID2DVINEYARD_H__
@@ -21,8 +21,11 @@
public:
typedef Grid2DVineyard Self;
- class VertexType;
- typedef std::vector<VertexType> VertexVector;
+ typedef Grid2D::CoordinateIndex CoordinateIndex;
+ typedef Grid2D::ValueType ValueType;
+
+ class KineticVertexType;
+ typedef std::vector<KineticVertexType> VertexVector;
typedef VertexVector::iterator VertexIndex;
typedef LowerStarFiltration<VertexIndex> LSFiltration;
@@ -31,12 +34,11 @@
class KineticEvaluator;
class VertexComparison;
- typedef Grid2D::CoordinateIndex CoordinateIndex;
- typedef Grid2D::ValueType ValueType;
-
typedef LSFiltration::Index Index;
typedef LSFiltration::Simplex Simplex;
typedef LSFiltration::VertexOrderIndex VertexOrderIndex;
+ typedef LSFiltration::VertexType<CoordinateIndex> LSVertexType;
+
typedef LSFiltration::Vineyard Vineyard;
typedef Vineyard::Evaluator Evaluator;
@@ -103,22 +105,15 @@
//BOOST_CLASS_EXPORT(Grid2DVineyard)
-class Grid2DVineyard::VertexType
+class Grid2DVineyard::KineticVertexType: public LSVertexType
{
public:
- VertexType(CoordinateIndex ii = 0): i_(ii) {}
-
- CoordinateIndex index() const { return i_; }
- void set_index(CoordinateIndex i) { i_ = i; }
- VertexOrderIndex get_order() const { return order_; }
- void set_order(const VertexOrderIndex& o) { order_ = o; }
+ typedef LSVertexType Parent;
Key kinetic_key() const { return key_; }
void set_kinetic_key(Key k) { key_ = k; }
private:
- CoordinateIndex i_;
- VertexOrderIndex order_;
Key key_;
};
--- a/include/topology/lowerstarfiltration.h Wed Feb 27 07:56:26 2008 -0500
+++ b/include/topology/lowerstarfiltration.h Wed Feb 27 07:57:45 2008 -0500
@@ -1,6 +1,6 @@
/*
* Author: Dmitriy Morozov
- * Department of Computer Science, Duke University, 2005 -- 2006
+ * Department of Computer Science, Duke University, 2005 -- 2008
*/
#ifndef __LOWERSTARFILTRATION_H__
@@ -41,6 +41,9 @@
typedef typename Parent::Trail Trail;
typedef typename Simplex::Cycle SimplexBoundaryCycle;
+ template<class IndexType>
+ class VertexType;
+
struct VertexDescriptor;
typedef ConsistencyList<VertexDescriptor> VertexOrder;
typedef typename VertexOrder::iterator VertexOrderIndex;
@@ -90,8 +93,34 @@
BOOST_SERIALIZATION_SPLIT_MEMBER()
};
+/**
+ * Helper class that describes lower star vertex type. Defines essential
+ * methods that LowerStarFiltration expects from its vertex type. Actual
+ * vertex types should inherit from it.
+ */
template<class VI, class Smplx, class FltrSmplx, class Vnrd>
-struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::VertexDescriptor
+template<class IndexType_>
+class LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+VertexType
+{
+ public:
+ typedef IndexType_ IndexType;
+
+ VertexType(IndexType ii = 0): i_(ii) {}
+
+ IndexType index() const { return i_; }
+ void set_index(IndexType i) { i_ = i; }
+ VertexOrderIndex get_order() const { return order_; }
+ void set_order(const VertexOrderIndex& o) { order_ = o; }
+
+ private:
+ IndexType i_;
+ VertexOrderIndex order_;
+};
+
+template<class VI, class Smplx, class FltrSmplx, class Vnrd>
+struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+VertexDescriptor
{
VertexDescriptor(VertexIndex vi, Index si):
vertex_index(vi), simplex_index(si)
@@ -102,7 +131,8 @@
};
template<class VI, class Smplx, class FltrSmplx, class Vnrd>
-struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::SimplexAttachmentComparison
+struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+SimplexAttachmentComparison
{
bool operator()(const Simplex& first, const Simplex& second) const;
VertexOrderComparison vertex_cmp;
--- a/include/topology/lowerstarfiltration.hpp Wed Feb 27 07:56:26 2008 -0500
+++ b/include/topology/lowerstarfiltration.hpp Wed Feb 27 07:57:45 2008 -0500
@@ -11,6 +11,11 @@
static Counter* cLowerStarChangedAttachment = GetCounter("lowerstar/ChangedAttachment");
#endif // COUNTERS
+
+/**
+ * Copies vertices [begin, end), orders them by cmp, and
+ * records which vineyard to use in case of transpositions.
+ */
template<class VI, class Smplx, class FltrSmplx, class Vnrd>
template<class VertexCmp>
LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
--- a/include/topology/simplex.h Wed Feb 27 07:56:26 2008 -0500
+++ b/include/topology/simplex.h Wed Feb 27 07:57:45 2008 -0500
@@ -171,6 +171,21 @@
void serialize(Archive& ar, version_type );
};
+template<class Simplex_>
+class DimensionValueComparison
+{
+ public:
+ typedef Simplex_ Simplex;
+
+ bool operator()(const Simplex& s1, const Simplex& s2) const
+ {
+ if (s1.dimension() == s2.dimension())
+ return s1.get_value() < s2.get_value();
+ else
+ return s1.dimension() < s2.dimension();
+ }
+};
+
#include "simplex.hpp"
#endif // __SIMPLEX_H__