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
|
#pragma once
#include "func/pred.hpp"
namespace omnigraph {
template<class Graph>
class VertexCondition : public func::AbstractPredicate<typename Graph::VertexId> {
typedef typename Graph::VertexId VertexId;
const Graph &g_;
protected:
VertexCondition(const Graph &g)
: g_(g) {
}
const Graph &g() const {
return g_;
}
};
template<class Graph>
class CompressCondition : public VertexCondition<Graph> {
typedef typename Graph::VertexId VertexId;
public:
CompressCondition(const Graph &g) :
VertexCondition<Graph>(g) {
}
bool Check(VertexId v) const override {
return this->g().CanCompressVertex(v);
}
};
template<class Graph>
class IsolatedVertexCondition : public VertexCondition<Graph> {
typedef typename Graph::VertexId VertexId;
public:
IsolatedVertexCondition(const Graph& g) :
VertexCondition<Graph>(g) {
}
bool Check(VertexId v) const override {
return this->g().IsDeadStart(v) && this->g().IsDeadEnd(v);
}
};
template<class Graph>
class TerminalVertexCondition : public VertexCondition<Graph> {
typedef typename Graph::VertexId VertexId;
public:
TerminalVertexCondition(const Graph& g) :
VertexCondition<Graph>(g) {
}
bool Check(VertexId v) const override {
return this->g().IncomingEdgeCount(v) + this->g().OutgoingEdgeCount(v) == 1;
}
};
}
|