30 #include <agrum/agrum.h> 33 #include <agrum/tools/graphs/graphElements.h> 35 #ifndef DOXYGEN_SHOULD_SKIP_THIS 52 INLINE Edge::Edge(NodeId aN1, NodeId aN2) :
53 n1(std::min(aN1, aN2)), n2(std::max(aN1, aN2)) {
55 GUM_CONSTRUCTOR(Edge);
60 INLINE Edge::Edge(
const Edge& src) : n1(src.n1), n2(src.n2) {
67 INLINE Edge& Edge::operator=(
const Edge& src) {
77 INLINE Edge::~Edge() {
84 INLINE NodeId Edge::other(NodeId id)
const {
90 GUM_ERROR(IdError, id <<
" does not belong to this edge");
96 INLINE NodeId Edge::first()
const {
return n1; }
100 INLINE NodeId Edge::second()
const {
return n2; }
104 INLINE
bool Edge::operator==(
const Edge& src)
const {
105 return ((n1 == src.n1) && (n2 == src.n2));
110 INLINE
bool Edge::operator!=(
const Edge& src)
const {
111 return ((n1 != src.n1) || (n2 != src.n2));
116 INLINE Size HashFunc< Edge >::castToSize(
const Edge& key) {
117 return Size(key.first()) * HashFuncConst::pi
118 + Size(key.second()) * HashFuncConst::gold;
122 INLINE Size HashFunc< Edge >::operator()(
const Edge& key)
const {
123 return castToSize(key) &
this->hash_mask_;
140 INLINE Arc::Arc(NodeId tail, NodeId head) : n1(tail), n2(head) {
142 GUM_CONSTRUCTOR(Arc);
147 INLINE Arc::Arc(
const Arc& src) : n1(src.n1), n2(src.n2) {
154 INLINE Arc& Arc::operator=(
const Arc& src) {
171 INLINE NodeId Arc::tail()
const {
return n1; }
175 INLINE
void Arc::setTail__(NodeId id) { n1 = id; }
179 INLINE NodeId Arc::head()
const {
return n2; }
183 INLINE
void Arc::setHead__(NodeId id) { n2 = id; }
187 INLINE NodeId Arc::other(NodeId id)
const {
193 GUM_ERROR(IdError, id <<
" does not belong to this arc");
199 INLINE NodeId Arc::first()
const {
return n1; }
203 INLINE NodeId Arc::second()
const {
return n2; }
207 INLINE
bool Arc::operator==(
const Arc& src)
const {
208 return ((n1 == src.n1) && (n2 == src.n2));
213 INLINE
bool Arc::operator!=(
const Arc& src)
const {
214 return ((n1 != src.n1) || (n2 != src.n2));
219 INLINE
void Arc::operator-() {
227 INLINE Size HashFunc< Arc >::castToSize(
const Arc& key) {
228 return Size(key.first()) * HashFuncConst::pi
229 + Size(key.second()) * HashFuncConst::gold;
233 INLINE Size HashFunc< Arc >::operator()(
const Arc& key)
const {
234 return castToSize(key) &
this->hash_mask_;