COIN-OR::LEMON - Graph Library

Changeset 6:b63d1bc367f7 in lemon-0.x


Ignore:
Timestamp:
12/16/03 17:19:08 (20 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@19
Message:

!!!Tests!!!

Location:
src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/include/bfs.h

    r5 r6  
    241241
    242242  // bfs algorithm class
     243
     244  template<class G>  //the default traits
     245  class default_bfs_T
     246  {
     247  public:
     248   
     249    typedef G Graph;
     250    typedef typename G::OutEdgeIterator SearchEdgeIterator;
     251   
     252    typedef typename G::NodeMap<bool> visited_map_t;
     253    typedef typename G::NodeMap<typename G::EdgeIterator> tree_map_t;
     254   
     255    typedef typename G::NodeMap<int> dist_map_t;   //node->int (W)
     256    typedef typename G::NodeMap<int> priority_map_t; //node->int (W)
     257};
     258
    243259  template<class T>
    244260  class Bfs
    245261  {
    246262  public:
    247     typedef typename T::Graph_t Graph;
     263    typedef typename T::Graph Graph;
    248264    typedef typename Graph::NodeIterator NodeIterator;
    249265    typedef typename Graph::EdgeIterator EdgeIterator;
  • src/include/graph.h

    r3 r6  
    55//inline void *operator new(size_t s, void *p) { return p; }
    66#include <new>
     7#include <vector>
    78
    89namespace NEGRO
     
    4142    class AllEdgeIterator;
    4243   
    43     class FirstAnythingTypeNode;
     44    class FirstAnythingTypeNode; //Required by the unified First() function.
    4445
    4546    friend class NodeIterator;
     
    392393
    393394    Graph() : _FST(this) {}
     395
     396    // MAPS:
     397    template<class T> class NodeMap
     398    {
     399      Graph<N,E> *G;
     400      vector<T> map;
     401
     402    public:
     403      typedef T value_type;
     404      void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
     405      T &Get(NodeIterator i) {return map[i.Index()];}
     406      T &operator[](NodeIterator i) {return map[i.Index()];}
     407
     408      void update() { map.resize(G->OldGraph<N,E>::NodeMax());}
     409
     410      NodeMap(Graph<N,E> &Gr) : map(Gr.OldGraph<N,E>::NodeMax()) { G=&Gr ;}
     411     
     412    };
     413
     414    template<class T> class EdgeMap
     415    {
     416      Graph<N,E> *G;
     417      vector<T> map;
     418
     419    public:
     420      typedef T value_type;
     421      void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
     422      T &Get(NodeIterator i) {return map[i.Index()];}
     423      T &operator[](NodeIterator i) {return map[i.Index()];}
     424     
     425      void update()
     426        { map.resize(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE);}
     427     
     428      EdgeMap(Graph<N,E> &Gr)
     429        :map(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE)
     430        { G=&Gr ;}
     431     
     432    };
     433   
    394434  };
    395435 
  • src/work/bfsdemo.cc

    r4 r6  
    8383public:
    8484
    85   typedef IGraph Graph_t;
     85  typedef IGraph Graph;
    8686  typedef IGraph::OutEdgeIterator SearchEdgeIterator;
    8787 
Note: See TracChangeset for help on using the changeset viewer.