COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
04/06/04 14:00:34 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@429
Message:

gw

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/graph_wrapper.h

    r307 r311  
    1313 
    1414  public:
     15//    typedef Graph BaseGraph;
    1516    typedef Graph ParentGraph;
    1617
     
    2526      NodeIt() { }
    2627      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
     28//      NodeIt(const typename BaseGraph::NodeIt& n) : Graph::NodeIt(n) { }
    2729      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
    2830      NodeIt(const TrivGraphWrapper<Graph>& _G) :
    2931        Graph::NodeIt(*(_G.graph)) { }
     32//      operator typename BaseGraph::NodeIt() {
     33//      return typename BaseGraph::NodeIt(this->Graph::NodeIt);
     34//      }
    3035    };
    3136    typedef typename Graph::Edge Edge;
     
    5863    NodeIt& first(NodeIt& i) const {
    5964      i=NodeIt(*this);
    60       return i;
    61     }
    62     EdgeIt& first(EdgeIt& i) const {
    63       i=EdgeIt(*this);
    6465      return i;
    6566    }
     
    7677      return i;
    7778    }
     79    EdgeIt& first(EdgeIt& i) const {
     80      i=EdgeIt(*this);
     81      return i;
     82    }
    7883//     template<typename I, typename P> I& first(I& i, const P& p) const {
    7984//       i=I(*this, p);
     
    8388//    template<typename I> I getNext(const I& i) const {
    8489//      return graph->getNext(i); }
    85     template<typename I> I& next(I &i) const { graph->next(i); return i; }   
     90//    template<typename I> I& next(I &i) const { graph->next(i); return i; }   
     91    NodeIt& next(NodeIt& i) const { graph->next(i); return i; }
     92    OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i); return i; }
     93    InEdgeIt& next(InEdgeIt& i) const { graph->next(i); return i; }
     94    EdgeIt& next(EdgeIt& i) const { graph->next(i); return i; }
    8695
    8796    template< typename It > It first() const {
     
    158167 
    159168  public:
     169    typedef Graph BaseGraph;
    160170    typedef Graph ParentGraph;
    161171
     
    205215      return i;
    206216    }
    207     EdgeIt& first(EdgeIt& i) const {
    208       i=EdgeIt(*this);
    209       return i;
    210     }
    211217//     template<typename I> I& first(I& i) const {       
    212218//       i=I(*this);
     
    221227      return i;
    222228    }
     229    EdgeIt& first(EdgeIt& i) const {
     230      i=EdgeIt(*this);
     231      return i;
     232    }
    223233//     template<typename I, typename P> I& first(I& i, const P& p) const {
    224234//       i=I(*this, p);
     
    228238//    template<typename I> I getNext(const I& i) const {
    229239//      return gw.getNext(i); }
    230     template<typename I> I& next(I &i) const { graph->next(i); return i; }   
     240//    template<typename I> I& next(I &i) const { graph->next(i); return i; }   
     241    NodeIt& next(NodeIt& i) const { graph->next(i); return i; }
     242    OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i); return i; }
     243    InEdgeIt& next(InEdgeIt& i) const { graph->next(i); return i; }
     244    EdgeIt& next(EdgeIt& i) const { graph->next(i); return i; }   
    231245
    232246    template< typename It > It first() const {
     
    386400
    387401  //Subgraph on the same node-set and partial edge-set
    388   template<typename Graph, typename EdgeFilterMap>
     402  template<typename Graph, typename NodeFilterMap,
     403           typename EdgeFilterMap>
    389404  class SubGraphWrapper : public GraphWrapper<Graph> {
    390405  protected:
    391     EdgeFilterMap* filter_map;
     406    NodeFilterMap* node_filter_map;
     407    EdgeFilterMap* edge_filter_map;
    392408  public:
    393     typedef typename GraphWrapper<Graph>::Node Node;
    394     typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
    395     typedef typename GraphWrapper<Graph>::Edge Edge;
    396     typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
    397     typedef typename GraphWrapper<Graph>::InEdgeIt InEdgeIt;
    398     typedef typename GraphWrapper<Graph>::OutEdgeIt OutEdgeIt;
    399 
    400409//     SubGraphWrapper() : GraphWrapper<Graph>(), filter_map(0) { }
    401     SubGraphWrapper(Graph& _graph, EdgeFilterMap& _filter_map) :
    402       GraphWrapper<Graph>(_graph), filter_map(&_filter_map) { } 
    403 
    404     template<typename I> I& first(I& i) const {
    405       graph->first(i);
    406       //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
    407       while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
    408       return i;
    409     }
    410     template<typename I, typename P> I& first(I& i, const P& p) const {
    411       graph->first(i, p);
    412 //      while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
    413       while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
    414       return i;
    415     }
    416    
     410    SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map,
     411                    EdgeFilterMap& _edge_filter_map) :
     412      GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map),
     413      edge_filter_map(&_edge_filter_map) { } 
     414
     415
     416    typedef typename Graph::Node Node;
     417    class NodeIt : public Graph::NodeIt {
     418//      typedef typename Graph::NodeIt GraphNodeIt;
     419    public:
     420      NodeIt() { }
     421      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
     422      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
     423      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
     424        Graph::NodeIt(*(_G.graph)) {
     425        while (_G.graph->valid((*this)/*.GraphNodeIt*/) &&
     426               !(*(_G.node_filter_map))[(*this)/*.GraphNodeIt*/])
     427          _G.graph->next((*this)/*.GraphNodeIt*/);
     428      }
     429    };
     430    typedef typename Graph::Edge Edge;
     431    class OutEdgeIt : public Graph::OutEdgeIt {
     432//      typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
     433    public:
     434      OutEdgeIt() { }
     435      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
     436      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
     437      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>&
     438                _G, const Node& n) :
     439        Graph::OutEdgeIt(*(_G.graph), n) {
     440        while (_G.graph->valid((*this)/*.GraphOutEdgeIt*/) &&
     441               !(*(_G.edge_filter_map))[(*this)/*.GraphOutEdgeIt*/])
     442          _G.graph->next((*this)/*.GraphOutEdgeIt*/);
     443      }
     444    };
     445    class InEdgeIt : public Graph::InEdgeIt {
     446//      typedef typename Graph::InEdgeIt GraphInEdgeIt;
     447    public:
     448      InEdgeIt() { }
     449      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
     450      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
     451      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G,
     452               const Node& n) :
     453        Graph::InEdgeIt(*(_G.graph), n) {
     454        while (_G.graph->valid((*this)/*.GraphInEdgeIt*/) &&
     455               !(*(_G.edge_filter_map))[(*this)/*.GraphInEdgeIt*/])
     456          _G.graph->next((*this)/*.GraphInEdgeIt*/);
     457      }
     458    };
     459//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
     460    class EdgeIt : public Graph::EdgeIt {
     461//      typedef typename Graph::EdgeIt GraphEdgeIt;
     462    public:
     463      EdgeIt() { }
     464      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
     465      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
     466      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
     467        Graph::EdgeIt(*(_G.graph)) {
     468        while (_G.graph->valid((*this)/*.GraphEdgeIt*/) &&
     469               !(*(_G.edge_filter_map))[(*this)/*.GraphEdgeIt*/])
     470          _G.graph->next((*this)/*.GraphEdgeIt*/);
     471      }
     472    };
     473   
     474    NodeIt& first(NodeIt& i) const {
     475      i=NodeIt(*this);
     476      return i;
     477    }
     478    OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
     479      i=OutEdgeIt(*this, n);
     480      return i;
     481    }
     482    InEdgeIt& first(InEdgeIt& i, const Node& n) const {
     483      i=InEdgeIt(*this, n);
     484      return i;
     485    }
     486    EdgeIt& first(EdgeIt& i) const {
     487      i=EdgeIt(*this);
     488      return i;
     489    }
     490   
     491//     template<typename I> I& first(I& i) const {
     492//       graph->first(i);
     493//       //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
     494//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     495//       return i;
     496//     }
     497//     template<typename I, typename P> I& first(I& i, const P& p) const {
     498//       graph->first(i, p);
     499// //      while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
     500//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     501//       return i;
     502//     }
     503
     504    NodeIt& next(NodeIt& i) const {
     505      graph->next(i);
     506      while (graph->valid(i) && !(*node_filter_map)[i]) { graph->next(i); }
     507      return i;
     508    }
     509    OutEdgeIt& next(OutEdgeIt& i) const {
     510      graph->next(i);
     511      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     512      return i;
     513    }
     514    InEdgeIt& next(InEdgeIt& i) const {
     515      graph->next(i);
     516      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     517      return i;
     518    }
     519    EdgeIt& next(EdgeIt& i) const {
     520      graph->next(i);
     521      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     522      return i;
     523    }
     524
    417525    //template<typename I> I getNext(const I& i) const {
    418526    //  return gw.getNext(i);
    419527    //}
    420     template<typename I> I& next(I &i) const {
    421       graph->next(i);
    422 //      while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
    423       while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
    424       return i;
    425     }
     528//     template<typename I> I& next(I &i) const {
     529//       graph->next(i);
     530// //      while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
     531//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
     532//       return i;
     533//     }
    426534   
    427535    template< typename It > It first() const {
     
    845953
    846954  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
    847   class ResGraphWrapper : public GraphWrapper<Graph>{
    848   public:
    849     typedef typename GraphWrapper<Graph>::Node Node;
    850     typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
     955  class ResGraphWrapper : public GraphWrapper<Graph> {
    851956  protected:
    852957    typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
     
    866971    friend class OutEdgeIt;
    867972
     973    typedef typename GraphWrapper<Graph>::Node Node;
     974    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
    868975    class Edge {
    869976      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
     
    8931000      }
    8941001    };
    895 
    896 
    8971002    class OutEdgeIt : public Edge {
    8981003      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
     
    9311036
    9321037    //FIXME This is just for having InEdgeIt
    933     typedef void InEdgeIt;
     1038//    class InEdgeIt : public Edge { };
    9341039
    9351040    class EdgeIt : public Edge {
     
    9941099    };
    9951100
    996     NodeIt& first(NodeIt& v) const { graph->first(v); return v; }
    997     OutEdgeIt& first(OutEdgeIt& e, Node v) const {
    998       e=OutEdgeIt(*this, v);
    999       return e;
    1000     }
     1101    NodeIt& first(NodeIt& i) const {
     1102      i=NodeIt(*this);
     1103      return i;
     1104    }
     1105    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
     1106      i=OutEdgeIt(*this, p);
     1107      return i;
     1108    }
     1109    //FIXME Not yet implemented
     1110    //InEdgeIt& first(InEdgeIt& i, const Node& p) const {
     1111    //i=InEdgeIt(*this, p);
     1112    //  return i;
     1113    //}
    10011114    EdgeIt& first(EdgeIt& e) const {
    10021115      e=EdgeIt(*this);
     
    10051118   
    10061119    NodeIt& next(NodeIt& n) const { graph->next(n); return n; }
    1007 
    10081120    OutEdgeIt& next(OutEdgeIt& e) const {
    10091121      if (e.out_or_in) {
     
    10221134      return e;
    10231135    }
    1024 
     1136    //FIXME Not yet implemented
     1137    //InEdgeIt& next(InEdgeIt& e) const {
     1138    //  return e;
     1139    //}
    10251140    EdgeIt& next(EdgeIt& e) const {
    10261141      if (e.out_or_in) {
     
    11701285    FirstOutEdgesMap* first_out_edges;
    11711286  public:
    1172     typedef typename GraphWrapper<Graph>::Node Node;
    1173     typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
    1174     typedef typename GraphWrapper<Graph>::Edge Edge;
    1175     typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
    1176     typedef typename GraphWrapper<Graph>::InEdgeIt InEdgeIt;
    1177     typedef typename GraphWrapper<Graph>::OutEdgeIt OutEdgeIt;
    1178 
    11791287    ErasingFirstGraphWrapper(Graph& _graph,
    11801288                             FirstOutEdgesMap& _first_out_edges) :
    11811289      GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { } 
    11821290
    1183     template<typename I> I& first(I& i) const {
    1184       graph->first(i);
    1185       return i;
    1186     }
    1187     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
    1188 //      e=first_out_edges->get(n);
    1189       e=(*first_out_edges)[n];
    1190       return e;
    1191     }
    1192     template<typename I, typename P> I& first(I& i, const P& p) const {
    1193       graph->first(i, p);
    1194       return i;
    1195     }
     1291    typedef typename Graph::Node Node;
     1292    class NodeIt : public Graph::NodeIt {
     1293    public:
     1294      NodeIt() { }
     1295      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
     1296      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
     1297      NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
     1298        Graph::NodeIt(*(_G.graph)) { }
     1299    };
     1300    typedef typename Graph::Edge Edge;
     1301    class OutEdgeIt : public Graph::OutEdgeIt {
     1302    public:
     1303      OutEdgeIt() { }
     1304      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
     1305      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
     1306      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
     1307                const Node& n) :
     1308        Graph::OutEdgeIt((*_G.first_out_edges)[n]) { }
     1309    };
     1310    class InEdgeIt : public Graph::InEdgeIt {
     1311    public:
     1312      InEdgeIt() { }
     1313      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
     1314      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
     1315      InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
     1316               const Node& n) :
     1317        Graph::InEdgeIt(*(_G.graph), n) { }
     1318    };
     1319    //typedef typename Graph::SymEdgeIt SymEdgeIt;
     1320    class EdgeIt : public Graph::EdgeIt {
     1321    public:
     1322      EdgeIt() { }
     1323      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
     1324      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
     1325      EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
     1326        Graph::EdgeIt(*(_G.graph)) { }
     1327    };
     1328
     1329    NodeIt& first(NodeIt& i) const {
     1330      i=NodeIt(*this);
     1331      return i;
     1332    }
     1333    OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
     1334      i=OutEdgeIt(*this, n);
     1335//      i=(*first_out_edges)[n];
     1336      return i;
     1337    }
     1338    InEdgeIt& first(InEdgeIt& i, const Node& n) const {
     1339      i=InEdgeIt(*this, n);
     1340      return i;
     1341    }
     1342    EdgeIt& first(EdgeIt& i) const {
     1343      i=EdgeIt(*this);
     1344      return i;
     1345    }
     1346
     1347//     template<typename I> I& first(I& i) const {
     1348//       graph->first(i);
     1349//       return i;
     1350//     }
     1351//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
     1352// //      e=first_out_edges->get(n);
     1353//       e=(*first_out_edges)[n];
     1354//       return e;
     1355//     }
     1356//     template<typename I, typename P> I& first(I& i, const P& p) const {
     1357//       graph->first(i, p);
     1358//       return i;
     1359//     }
    11961360   
    11971361    //template<typename I> I getNext(const I& i) const {
    11981362    //  return gw.getNext(i);
    11991363    //}
    1200     template<typename I> I& next(I &i) const {
     1364
     1365
     1366    NodeIt& next(NodeIt& i) const {
    12011367      graph->next(i);
    12021368      return i;
    12031369    }
     1370    OutEdgeIt& next(OutEdgeIt& i) const {
     1371      graph->next(i);
     1372      return i;
     1373    }
     1374    InEdgeIt& next(InEdgeIt& i) const {
     1375      graph->next(i);
     1376      return i;
     1377    }
     1378    EdgeIt& next(EdgeIt& i) const {
     1379      graph->next(i);
     1380      return i;
     1381    }
     1382
     1383//     template<typename I> I& next(I &i) const {
     1384//       graph->next(i);
     1385//       return i;
     1386//     }
    12041387   
    12051388    template< typename It > It first() const {
Note: See TracChangeset for help on using the changeset viewer.