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)) {
54 GUM_CONSTRUCTOR(Edge);
59 INLINE Edge::Edge(
const Edge& src) : n1(src.n1), n2(src.n2) {
65 INLINE Edge& Edge::operator=(
const Edge& src) {
75 INLINE Edge::~Edge() {
81 INLINE NodeId Edge::other(NodeId id)
const {
87 GUM_ERROR(IdError, id <<
" does not belong to this edge")
93 INLINE NodeId Edge::first()
const {
return n1; }
97 INLINE NodeId Edge::second()
const {
return n2; }
101 INLINE
bool Edge::operator==(
const Edge& src)
const {
return ((n1 == src.n1) && (n2 == src.n2)); }
105 INLINE
bool Edge::operator!=(
const Edge& src)
const {
return ((n1 != src.n1) || (n2 != src.n2)); }
109 INLINE Size HashFunc< Edge >::castToSize(
const Edge& key) {
110 return Size(key.first()) * HashFuncConst::pi + Size(key.second()) * HashFuncConst::gold;
114 INLINE Size HashFunc< Edge >::operator()(
const Edge& key)
const {
115 return castToSize(key) &
this->hash_mask_;
132 INLINE Arc::Arc(NodeId tail, NodeId head) : n1(tail), n2(head) {
133 GUM_CONSTRUCTOR(Arc);
138 INLINE Arc::Arc(
const Arc& src) : n1(src.n1), n2(src.n2) {
144 INLINE Arc& Arc::operator=(
const Arc& src) {
160 INLINE NodeId Arc::tail()
const {
return n1; }
164 INLINE
void Arc::_setTail_(NodeId id) { n1 = id; }
168 INLINE NodeId Arc::head()
const {
return n2; }
172 INLINE
void Arc::_setHead_(NodeId id) { n2 = id; }
176 INLINE NodeId Arc::other(NodeId id)
const {
182 GUM_ERROR(IdError, id <<
" does not belong to this arc")
188 INLINE NodeId Arc::first()
const {
return n1; }
192 INLINE NodeId Arc::second()
const {
return n2; }
196 INLINE
bool Arc::operator==(
const Arc& src)
const {
return ((n1 == src.n1) && (n2 == src.n2)); }
200 INLINE
bool Arc::operator!=(
const Arc& src)
const {
return ((n1 != src.n1) || (n2 != src.n2)); }
204 INLINE
void Arc::operator-() {
212 INLINE Size HashFunc< Arc >::castToSize(
const Arc& key) {
213 return Size(key.first()) * HashFuncConst::pi + Size(key.second()) * HashFuncConst::gold;
217 INLINE Size HashFunc< Arc >::operator()(
const Arc& key)
const {
218 return castToSize(key) &
this->hash_mask_;