COIN-OR::LEMON - Graph Library

Ticket #325: stl-iterators-Bellman-Ford-79271f3a7b98.patch

File stl-iterators-Bellman-Ford-79271f3a7b98.patch, 2.7 KB (added by Gábor Gévay, 11 years ago)
  • contrib/stlit_test/stlit_test.cc

    # HG changeset patch
    # User Gabor Gevay <ggab90@gmail.com>
    # Date 1390056610 -3600
    #      Sat Jan 18 15:50:10 2014 +0100
    # Node ID 79271f3a7b98e3797fdd852d73f9637a01b4092c
    # Parent  fe4d0623659c53def73f443f989632de7ae96520
    STL style iterator for Bellman-Ford ActiveIt.
    
    diff --git a/contrib/stlit_test/stlit_test.cc b/contrib/stlit_test/stlit_test.cc
    a b  
    88#include <lemon/smart_graph.h>
    99#include <lemon/path.h>
    1010#include <lemon/bfs.h>
     11#include <lemon/bellman_ford.h>
     12#include <lemon/euler.h>
    1113
    1214
    1315using namespace std;
     
    141143      cout<<g4.id(g4.target(a))<<endl;
    142144  }
    143145
     146//  cout<<endl;
     147
     148//  {
     149//    SmartDigraph g;
     150//    auto u=g.addNode(), v=g.addNode();
     151//    g.addArc(u,v); g.addArc(u,v);
     152//    int c=0;
     153//    for(auto a: conArcs(g,u,v))
     154//    //for(ConArcIt<SmartDigraph> a(g,u,v); a!=INVALID; ++a)
     155//      c++;
     156//    cout<<c<<endl;
     157//  }
     158
     159//  {
     160//    SmartDigraph g;
     161//    auto u=g.addNode(), v=g.addNode();
     162//    g.addArc(u,v);  g.addArc(v,u);
     163//    //for(auto a: diEulerTour(g,u))
     164//    //for(auto a=diEulerTour(g,u).begin(); a!=INVALID; ++a)
     165//    //  cout<<g.id(g.target(a))<<endl;
     166//    auto t = diEulerTour(g,u);
     167//    auto a = t.begin();
     168//  }
     169
     170
     171
    144172  return 0;
    145173}
     174
     175
     176void checkBellmanFordCompile()
     177{
     178  typedef int Value;
     179  typedef concepts::Digraph Digraph;
     180  typedef concepts::ReadMap<Digraph::Arc,Value> LengthMap;
     181  typedef BellmanFord<Digraph, LengthMap> BF;
     182
     183  Digraph gr;
     184  LengthMap length;
     185
     186  {
     187    BF bf_test(gr,length);
     188    const BF& const_bf_test = bf_test;
     189
     190    for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {}
     191    for (BF::ActiveIt it(bf_test); it != INVALID; ++it) {}
     192  }
     193}
  • lemon/bellman_ford.h

    diff --git a/lemon/bellman_ford.h b/lemon/bellman_ford.h
    a b  
    690690      int _index;
    691691    };
    692692
     693    /// \brief Gets the collection of the active nodes.
     694    ///
     695    /// This function can be used for iterating on the active nodes of the
     696    /// Bellman-Ford algorithm after the last phase.
     697    /// These nodes should be checked in the next phase to
     698    /// find augmenting arcs outgoing from them.
     699    /// It returns a wrapped ActiveIt, which looks
     700    /// like an STL container (by having begin() and end())
     701    /// which you can use in range-based for loops, stl algorithms, etc.
     702    LemonRangeWrapper1<ActiveIt, BellmanFord>
     703        activeNodes(const BellmanFord& algorithm) const {
     704      return LemonRangeWrapper1<ActiveIt, BellmanFord>(algorithm);
     705    }
     706
     707
    693708    /// \name Query Functions
    694709    /// The result of the Bellman-Ford algorithm can be obtained using these
    695710    /// functions.\n