examples/triangle/triangle.cpp
author Dmitriy Morozov <morozov@cs.duke.edu>
Tue, 30 Jan 2007 13:51:04 -0500
changeset 15 ef3bf83302ca
parent 9 4ed0ecccba8c
child 20 7bf6aa6b0ab6
permissions -rw-r--r--
Switched to CMake

#include "filtration.h"
#include "simplex.h"
#include <vector>
#include <iostream>

typedef 		SimplexWithValue<int> 			Simplex;
typedef			Filtration<Simplex>				TriangleFiltration;

void fillTriangleSimplices(TriangleFiltration& f)
{
	typedef std::vector<int> VertexVector;
	VertexVector vertices(4);
	vertices[0] = 0; vertices[1] = 1; vertices[2] = 2; 
	vertices[3] = 0;
		
	VertexVector::const_iterator bg = vertices.begin();
	VertexVector::const_iterator end = vertices.end();
	f.append(Simplex(bg,     bg + 1, 0));				// 0 = A
	f.append(Simplex(bg + 1, bg + 2, 1));				// 1 = B
	f.append(Simplex(bg + 2, bg + 3, 2));				// 2 = C
	f.append(Simplex(bg,     bg + 2, 2.5));				// AB
	f.append(Simplex(bg + 1, bg + 3, 2.9));				// BC
	f.append(Simplex(bg + 2, end, 3.5));				// CA
	f.append(Simplex(bg,     bg + 3, 5));				// ABC
}

int main()
{
#ifdef CWDEBUG
	dionysus::debug::init();

	Debug(dc::filtration.on());
	Debug(dc::cycle.off());
	Debug(dc::vineyard.on());
	Debug(dc::transpositions.on());
#endif

	Evaluator<Simplex> e;
	TriangleFiltration::Vineyard v(&e);
	TriangleFiltration tf(&v);
	fillTriangleSimplices(tf);
	
	tf.fill_simplex_index_map();
	tf.pair_simplices();
	v.start_vines(tf.begin(), tf.end());
	
	std::cout << "Filtration size: " << tf.size() << std::endl;
	std::cout << tf << std::endl;

#if 1
	Simplex BC; BC.add(1); BC.add(2);
	Simplex AB; AB.add(0); AB.add(1);
	std::cout << BC << std::endl;
	std::cout << *tf.get_index(BC) << std::endl;
	tf.transpose(tf.get_index(BC));
	std::cout << tf;
	std::cout << AB << std::endl;
	std::cout << *tf.get_index(AB) << std::endl;
	tf.transpose(tf.get_index(AB));
	std::cout << tf;
#endif
}