# Ticket #309: 309-listdigraph-arcit-c6157e490d8c.patch

File 309-listdigraph-arcit-c6157e490d8c.patch, 1.5 KB (added by Peter Kovacs, 12 years ago)
• ## lemon/list_graph.h

```# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1250599376 -7200
# Node ID c6157e490d8c52ec14e1b57c14e0df59d450eccd
# Parent  9f529abcaebf13f19e61ba24fdd2c3631860af91
Modify the implementation of ListDigraph::ArcIt (#309)

The new implementation is based on out-arc iteration (like
ListGraph::ArcIt) instead of in-arc iteration. It could be
better if the outgoing arcs of the nodes were added to the
graph near to each other, which seems to be a typical case.

diff --git a/lemon/list_graph.h b/lemon/list_graph.h```
 a void first(Arc& arc) const { int n; for(n = first_node; n!=-1 && nodes[n].first_in == -1; n != -1 && nodes[n].first_out == -1; n = nodes[n].next) {} arc.id = (n == -1) ? -1 : nodes[n].first_in; arc.id = (n == -1) ? -1 : nodes[n].first_out; } void next(Arc& arc) const { if (arcs[arc.id].next_in != -1) { arc.id = arcs[arc.id].next_in; if (arcs[arc.id].next_out != -1) { arc.id = arcs[arc.id].next_out; } else { int n; for(n = nodes[arcs[arc.id].target].next; n!=-1 && nodes[n].first_in == -1; for(n = nodes[arcs[arc.id].source].next; n != -1 && nodes[n].first_out == -1; n = nodes[n].next) {} arc.id = (n == -1) ? -1 : nodes[n].first_in; arc.id = (n == -1) ? -1 : nodes[n].first_out; } }