1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
////////////////////////////////////////////////////////////////////////////////
//
// TriangNode.cc
//
// produced: 19/04/98 jr
// last change: 18/06/98 jr
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <set>
#include "Circuits.hh"
#include "TriangNode.hh"
namespace topcom {
// functions:
bool TriangNode::containment_ok(const Circuit& circuit) const {
const Simplex c_support(circuit.support());
bool ok(true);
for (Simplex::const_iterator iter = circuit.first.begin();
iter != circuit.first.end();
++iter) {
const Simplex current(c_support - *iter);
if (!contains(current)) {
return false;
}
}
return true;
}
bool TriangNode::link_ok(const Circuit& circuit) const {
if (circuit.second.empty()) {
return false;
}
std::set<Simplex> common_link;
const Simplex c_support(circuit.support());
if (c_support.card() == _rank + 1) {
common_link.insert(Simplex());
return true;
}
Simplex::iterator iter = circuit.first.begin();
const Simplex current(c_support - *iter);
for (SimplicialComplex::const_iterator tn_iter = begin();
tn_iter != end();
++tn_iter) {
if (tn_iter->superset(current)) {
common_link.insert(*tn_iter - current);
}
}
if (common_link.empty()) {
return false;
}
const size_type card = common_link.size();
while (++iter != circuit.first.end()) {
const Simplex next(c_support - *iter);
size_type count(0);
for (SimplicialComplex::const_iterator tn_iter = begin();
tn_iter != end();
++tn_iter) {
if (tn_iter->superset(next)) {
const Simplex link_elem(*tn_iter - next);
if (common_link.find(link_elem) == common_link.end()) {
return false;
}
++count;
}
}
if (count != card) {
return false;
}
}
return true;
}
}; // namespace topcom
// eof TriangNode.cc
|