# HG changeset patch # User alpar # Date 1100348641 0 # Node ID 741f3108a90f740f5b99af8d18a448d87a0b29d3 # Parent f7538f6f4c61cca18f99451b82d2ccf14aba6d7c Bugfixes in UndirFullGraphBase diff -r f7538f6f4c61 -r 741f3108a90f src/lemon/full_graph.h --- a/src/lemon/full_graph.h Thu Nov 11 12:12:28 2004 +0000 +++ b/src/lemon/full_graph.h Sat Nov 13 12:24:01 2004 +0000 @@ -296,7 +296,7 @@ class Node { - friend class FullGraphBase; + friend class UndirFullGraphBase; protected: int id; @@ -312,14 +312,14 @@ class Edge { - friend class FullGraphBase; + friend class UndirFullGraphBase; protected: int id; // NodeNum * head + tail; Edge(int _id) : id(_id) {} - Edge(const FullGraphBase& _graph, int tail, int head) + Edge(const UndirFullGraphBase& _graph, int tail, int head) : id(_graph.NodeNum * head+tail) {} public: Edge() { } @@ -350,22 +350,22 @@ } /// \todo with specialized iterators we can make faster iterating - void nextOut(Edge& edge) const { + void nextOut(Edge& e) const { int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;; int head = e.id - (tail) * (tail - 1) / 2; ++head; - return head < tail ? tail * (tail - 1) / 2 + head : -1; + e.id = head < tail ? tail * (tail - 1) / 2 + head : -1; } void firstIn(Edge& edge, const Node& node) const { edge.id = node.id * (node.id + 1) / 2 - 1; } - void nextIn(Edge& edge) const { + void nextIn(Edge& e) const { int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;; int head = e.id - (tail) * (tail - 1) / 2; ++head; ++tail; - return tail < nodeNum ? tail * (tail - 1) / 2 + head : -1; + e.id = tail < NodeNum ? tail * (tail - 1) / 2 + head : -1; } };