src/work/marci/graph_wrapper.h
changeset 263 f24f276e0b6b
parent 259 509ba9f136d2
child 265 bf7aea53635a
     1.1 --- a/src/work/marci/graph_wrapper.h	Mon Mar 29 21:43:27 2004 +0000
     1.2 +++ b/src/work/marci/graph_wrapper.h	Tue Mar 30 07:07:44 2004 +0000
     1.3 @@ -91,7 +91,7 @@
     1.4      GraphWrapper gw;
     1.5    
     1.6    public:
     1.7 -    typedef typename GraphWrapper::BaseGraph BaseGraph;
     1.8 +    //typedef typename GraphWrapper::BaseGraph BaseGraph;
     1.9  
    1.10      typedef typename GraphWrapper::Node Node;
    1.11      typedef typename GraphWrapper::NodeIt NodeIt;
    1.12 @@ -105,8 +105,8 @@
    1.13      //GraphWrapperSkeleton() : gw() { }
    1.14      GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { }
    1.15  
    1.16 -    void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
    1.17 -    BaseGraph& getGraph() const { return gw.getGraph(); }
    1.18 +    //void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
    1.19 +    //BaseGraph& getGraph() const { return gw.getGraph(); }
    1.20      
    1.21      template<typename I> I& first(I& i) const { return gw.first(i); }
    1.22      template<typename I, typename P> I& first(I& i, const P& p) const { 
    1.23 @@ -342,6 +342,48 @@
    1.24        { return GraphWrapperSkeleton<GraphWrapper>::head(e); }
    1.25    };
    1.26  
    1.27 +  //Subgraph on the same node-set and partial edge-set
    1.28 +  template<typename GraphWrapper, typename EdgeFilterMap>
    1.29 +  class SubGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
    1.30 +  protected:
    1.31 +    EdgeFilterMap* filter_map;
    1.32 +  public:
    1.33 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
    1.34 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
    1.35 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
    1.36 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::EdgeIt EdgeIt;
    1.37 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt InEdgeIt;
    1.38 +    typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OutEdgeIt;
    1.39 +
    1.40 +    SubGraphWrapper(GraphWrapper _gw, EdgeFilterMap& _filter_map) : 
    1.41 +      GraphWrapperSkeleton<GraphWrapper>(_gw), filter_map(&_filter_map) { }  
    1.42 +
    1.43 +    template<typename I> I& first(I& i) const { 
    1.44 +      gw.first(i); 
    1.45 +      while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
    1.46 +      return i;
    1.47 +    }
    1.48 +    template<typename I, typename P> I& first(I& i, const P& p) const { 
    1.49 +      gw.first(i, p); 
    1.50 +      while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
    1.51 +      return i;
    1.52 +    }
    1.53 +    
    1.54 +    //template<typename I> I getNext(const I& i) const { 
    1.55 +    //  return gw.getNext(i); 
    1.56 +    //}
    1.57 +    template<typename I> I& next(I &i) const { 
    1.58 +      gw.next(i); 
    1.59 +      while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
    1.60 +      return i;
    1.61 +    }
    1.62 +    
    1.63 +    template< typename It > It first() const { 
    1.64 +      It e; this->first(e); return e; }
    1.65 +    
    1.66 +    template< typename It > It first(const Node& v) const { 
    1.67 +      It e; this->first(e, v); return e; }
    1.68 +  };
    1.69  
    1.70  //   template<typename GraphWrapper>
    1.71  //   class UndirGraphWrapper {
    1.72 @@ -858,6 +900,9 @@
    1.73  //       }
    1.74      };
    1.75  
    1.76 +    //FIXME This is just for having InEdgeIt
    1.77 +    typedef void InEdgeIt;
    1.78 +
    1.79      class EdgeIt : public Edge {
    1.80        friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
    1.81        typename Graph::NodeIt v;
    1.82 @@ -1005,6 +1050,11 @@
    1.83      Node bNode(OutEdgeIt e) const { 
    1.84        return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
    1.85  
    1.86 +    int nodeNum() const { return gw.nodeNum(); }
    1.87 +    //FIXME
    1.88 +    //int edgeNum() const { return gw.edgeNum(); }
    1.89 +
    1.90 +
    1.91      int id(Node v) const { return gw.id(v); }
    1.92  
    1.93      bool valid(Node n) const { return gw.valid(n); }