Changeset 774:4297098d9677 in lemon-0.x for src/hugo/full_graph.h
- Timestamp:
- 08/30/04 14:01:47 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1066
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/full_graph.h
r752 r774 64 64 Node head(Edge e) const { return e.n/NodeNum; } 65 65 66 Node aNode(OutEdgeIt e) const { return tail(e); }67 Node aNode(InEdgeIt e) const { return head(e); }68 69 Node bNode(OutEdgeIt e) const { return head(e); }70 Node bNode(InEdgeIt e) const { return tail(e); }71 72 66 NodeIt& first(NodeIt& v) const { 73 67 v=NodeIt(*this); return v; } … … 79 73 e=InEdgeIt(*this,v); return e; } 80 74 81 static bool valid(Edge e) { return e.n!=-1; }82 static bool valid(Node n) { return n.n!=-1; }83 84 template <typename It> It getNext(It it) const85 { It tmp(it); return next(tmp); }86 87 NodeIt& next(NodeIt& it) const {88 it.n=(it.n+2)%(NodeNum+1)-1;89 return it;90 }91 OutEdgeIt& next(OutEdgeIt& it) const92 { it.n+=NodeNum; if(it.n>=EdgeNum) it.n=-1; return it; }93 InEdgeIt& next(InEdgeIt& it) const94 { if(!((++it.n)%NodeNum)) it.n=-1; return it; }95 static EdgeIt& next(EdgeIt& it) { --it.n; return it; }96 97 75 static int id(Node v) { return v.n; } 98 76 static int id(Edge e) { return e.n; } 99 77 78 /// Finds an edge between two nodes. 79 80 /// Finds an edge from node \c u to node \c v. 81 /// 82 /// If \c prev is \ref INVALID (this is the default value), then 83 /// It finds the first edge from \c u to \c v. Otherwise it looks for 84 /// the next edge from \c u to \c v after \c prev. 85 /// \return The found edge or INVALID if there is no such an edge. 86 Edge findEdge(Node u,Node v, Edge prev = INVALID) 87 { 88 return prev.n==-1?Edge(*this,u.n,v.n):INVALID; 89 } 90 91 100 92 class Node { 101 93 friend class FullGraph; … … 120 112 121 113 class NodeIt : public Node { 114 const FullGraph *G; 122 115 friend class FullGraph; 123 116 public: 124 117 NodeIt() : Node() { } 118 NodeIt(const FullGraph& _G,Node n) : Node(n), G(&_G) { } 125 119 NodeIt(Invalid i) : Node(i) { } 126 NodeIt(const FullGraph& G) : Node(G.NodeNum?0:-1) { }120 NodeIt(const FullGraph& _G) : Node(_G.NodeNum?0:-1), G(&_G) { } 127 121 ///\todo Undocumented conversion Node -\> NodeIt. 128 NodeIt (const FullGraph& G, const Node &n) : Node(n) {}122 NodeIt& operator++() { n=(n+2)%(G->NodeNum+1)-1;return *this; } 129 123 }; 130 124 … … 139 133 friend int FullGraph::id(Edge e); 140 134 141 Edge(int nn) {n=nn;} 135 Edge(int nn) : n(nn) {} 136 Edge(const FullGraph &G, int tail, int head) : n(G.NodeNum*head+tail) {} 142 137 public: 143 138 Edge() { } … … 155 150 friend class FullGraph; 156 151 public: 157 EdgeIt(const FullGraph& G) : Edge(G.EdgeNum-1) { } 152 EdgeIt(const FullGraph& _G) : Edge(_G.EdgeNum-1) { } 153 EdgeIt(const FullGraph&, Edge e) : Edge(e) { } 158 154 EdgeIt (Invalid i) : Edge(i) { } 159 155 EdgeIt() : Edge() { } 156 EdgeIt& operator++() { --n; return *this; } 157 160 158 ///\bug This is a workaround until somebody tells me how to 161 159 ///make class \c SymFullGraph::SymEdgeMap friend of Edge … … 164 162 165 163 class OutEdgeIt : public Edge { 164 const FullGraph *G; 166 165 friend class FullGraph; 167 166 public: 168 167 OutEdgeIt() : Edge() { } 168 OutEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { } 169 169 OutEdgeIt (Invalid i) : Edge(i) { } 170 170 171 OutEdgeIt(const FullGraph& G,const Node v) 172 : Edge(v.n) {} 171 OutEdgeIt(const FullGraph& _G,const Node v) : Edge(v.n), G(&_G) {} 172 173 OutEdgeIt& operator++() 174 { n+=G->NodeNum; if(n>=G->EdgeNum) n=-1; return *this; } 175 173 176 }; 174 177 175 178 class InEdgeIt : public Edge { 179 const FullGraph *G; 176 180 friend class FullGraph; 177 181 public: 178 182 InEdgeIt() : Edge() { } 183 InEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { } 179 184 InEdgeIt (Invalid i) : Edge(i) { } 180 InEdgeIt(const FullGraph& G,Node v) :Edge(v.n*G.NodeNum){} 185 InEdgeIt(const FullGraph& _G,Node v) : Edge(v.n*_G.NodeNum), G(&_G) {} 186 InEdgeIt& operator++() 187 { if(!((++n)%G->NodeNum)) n=-1; return *this; } 181 188 }; 182 189 … … 280 287 return *this; 281 288 } 282 289 283 290 void update() {} 284 291 void update(T a) {}
Note: See TracChangeset
for help on using the changeset viewer.