Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

# bellman_ford.h

    00001 //==========================================================================
    00002 //
    00003 //   bellman_ford.h
    00004 //
    00005 //==========================================================================
    00006 // $Id: bellman_ford.h,v 1.5 2003/03/24 15:58:54 raitner Exp $
    00007
    00008 #ifndef GTL_BELLMAN_FORD_H
    00009 #define GTL_BELLMAN_FORD_H
    00010
    00011 #include <GTL/GTL.h>
    00012 #include <GTL/algorithm.h>
    00013 #include <GTL/node_map.h>
    00014 #include <GTL/edge_map.h>
    00015
    00016 __GTL_BEGIN_NAMESPACE
    00017
    00018
    00032 class GTL_EXTERN bellman_ford : public algorithm
    00033 {
    00034 public:
    00035
    00039     bellman_ford();
    00040
    00044     virtual ~bellman_ford();
    00045
    00057     int check (graph& G);
    00058
    00059     int run (graph& G);
    00060
    00067     void reset ();
    00068
    00078     void source (const node& n) {s = n;}
    00079
    00085     node source () const {return s;}
    00086
    00094     void weights (const edge_map<double>& weight) {w = weight; vars_set = true; }
    00095
    00106     void store_preds (bool set);
    00107
    00116     bool store_preds () const {return preds != 0;}
    00117
    00123     bool reached (const node& n) const {return !inf[n];}
    00124
    00130     double distance (const node& n) const {return d[n];}
    00131
    00146     edge predecessor_edge (const node& n) const
    00147         {assert (preds); return (*preds)[n];}
    00148
    00163     node predecessor_node (const node& n) const
    00164         {edge e = predecessor_edge(n); return e == edge() ? node() : e.opposite(n); }
    00165
    00170     bool negative_cycle() const
    00171         {return cycle;}
    00172
    00173 private:
    00174
    00175
    00181     void relax (const edge& e, bool dir);
    00182
    00188     node s;
    00189
    00195     edge_map<double> w;
    00196
    00202     bool vars_set;
    00203
    00209     node_map<double> d;
    00210
    00216     node_map<bool> inf;
    00217
    00223     node_map<edge>* preds;
    00224
    00231     bool cycle;
    00232 };
    00233
    00234 __GTL_END_NAMESPACE
    00235
    00236 #endif // GTL_BELLMAN_FORD_H

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau