# HG changeset patch
# User Gabriel Gouvine <gabriel.gouvine.GIT@gmx.com>
# Date 1488481030 -3600
#      Thu Mar 02 19:57:10 2017 +0100
# Node ID b127b5408042aebd5f559a888d807fa4e596d61e
# Parent  fd04b9f2058dc6979eb27fe01835b9e5c38e9034
Remove arc_next_out from StaticDigraphBase

* Was only used in DigraphExtender::OutArcIt, overwritten in StaticDigraph
* Space complexity is now 2n + 3m (from 2n + 4m)
* nextOut(Arc &) redefined for compatibility

diff -r fd04b9f2058d -r b127b5408042 lemon/static_graph.h
--- a/lemon/static_graph.h	Fri Jan 27 20:35:13 2017 +0100
+++ b/lemon/static_graph.h	Thu Mar 02 19:57:10 2017 +0100
@@ -36,7 +36,7 @@
       : built(false), node_num(0), arc_num(0),
         node_first_out(NULL), node_first_in(NULL),
         arc_source(NULL), arc_target(NULL),
-        arc_next_in(NULL), arc_next_out(NULL) {}
+        arc_next_in(NULL) {}
 
     ~StaticDigraphBase() {
       if (built) {
@@ -44,7 +44,6 @@
         delete[] node_first_in;
         delete[] arc_source;
         delete[] arc_target;
-        delete[] arc_next_out;
         delete[] arc_next_in;
       }
     }
@@ -88,7 +87,13 @@
       e.id = node_first_out[n.id] != node_first_out[n.id + 1] ?
         node_first_out[n.id] : -1;
     }
-    void nextOut(Arc& e) const { e.id = arc_next_out[e.id]; }
+    void nextOut(Arc& e) const {
+      Node n = source(e);
+      Arc last;
+      fastLastOut(last, n);
+      ++e.id;
+      if (e == last) e.id = -1;
+    }
 
     void firstIn(Arc& e, const Node& n) const { e.id = node_first_in[n.id]; }
     void nextIn(Arc& e) const { e.id = arc_next_in[e.id]; }
@@ -135,7 +140,6 @@
         delete[] node_first_in;
         delete[] arc_source;
         delete[] arc_target;
-        delete[] arc_next_out;
         delete[] arc_next_in;
       }
       built = false;
@@ -158,7 +162,6 @@
 
       arc_source = new int[arc_num];
       arc_target = new int[arc_num];
-      arc_next_out = new int[arc_num];
       arc_next_in = new int[arc_num];
 
       int node_index = 0;
@@ -188,10 +191,8 @@
             arc_target[arc_index] = target;
             arc_next_in[arc_index] = node_first_in[target];
             node_first_in[target] = arc_index;
-            arc_next_out[arc_index] = arc_index + 1;
             ++arc_index;
           }
-          arc_next_out[arc_index - 1] = -1;
         } else {
           node_first_out[source] = arc_index;
         }
@@ -211,7 +212,6 @@
 
       arc_source = new int[arc_num];
       arc_target = new int[arc_num];
-      arc_next_out = new int[arc_num];
       arc_next_in = new int[arc_num];
 
       for (int i = 0; i != node_num; ++i) {
@@ -229,11 +229,8 @@
           arc_target[arc_index] = j;
           arc_next_in[arc_index] = node_first_in[j];
           node_first_in[j] = arc_index;
-          arc_next_out[arc_index] = arc_index + 1;
           ++arc_index;
         }
-        if (arc_index > node_first_out[i])
-          arc_next_out[arc_index - 1] = -1;
       }
       LEMON_ASSERT(first == last,
         "Wrong arc list for StaticDigraph::build()");
@@ -262,7 +259,6 @@
     int *arc_source;
     int *arc_target;
     int *arc_next_in;
-    int *arc_next_out;
   };
 
   typedef DigraphExtender<StaticDigraphBase> ExtendedStaticDigraphBase;
