COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
04/26/04 11:54:24 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@542
Message:

stGraphWrapper is almost working

File:
1 edited

Legend:

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

    r406 r409  
    924924
    925925  public:
    926     static const bool S_CLASS=false;
    927     static const bool T_CLASS=true;
     926    //marci
     927    //FIXME vhogy igy kellene, csak az en forditom nem eszi meg
     928    //static const bool S_CLASS=false;
     929    //static const bool T_CLASS=true;
    928930   
     931    bool S_CLASS;
     932    bool T_CLASS;
     933
    929934    BipartiteGraphWrapper(Graph& _graph, SFalseTTrueMap& _s_false_t_true_map)
    930       : GraphWrapper<Graph>(_graph), s_false_t_true_map(&_s_false_t_true_map) {
    931     }
     935      : GraphWrapper<Graph>(_graph), s_false_t_true_map(&_s_false_t_true_map),
     936      S_CLASS(false), T_CLASS(true) { }
    932937    typedef typename GraphWrapper<Graph>::Node Node;
    933938    //using GraphWrapper<Graph>::NodeIt;
     
    11031108//invalid, 3, invalid)
    11041109    template <typename T> class NodeMap;
    1105     template <typename T> class EdgeMap;
     1110    template <typename T, typename Parent> class EdgeMap;
    11061111
    11071112//    template <typename T> friend class NodeMap;
     
    11421147                static_cast<typename Graph::Node>(u)!=
    11431148                static_cast<typename Graph::Node>(v));
    1144       }
     1149      }
     1150      friend std::ostream& operator<<(std::ostream& os, const Node& i);
    11451151      int getSpec() const { return spec; }
    11461152    };
     1153
    11471154    class NodeIt {
    11481155      friend class GraphWrapper<Graph>;
     
    11561163      NodeIt(const Invalid& i) : n(i), spec(3) { }
    11571164      NodeIt(const stGraphWrapper<Graph>& _G) : n(*(_G.graph)), spec(0) {
    1158         if (!_G->valid(n)) spec=1;
     1165        if (!_G.graph->valid(n)) spec=1;
    11591166      }
    11601167      operator Node() const { return Node(n, spec); }
    11611168    };
     1169
    11621170    class Edge : public Graph::Edge {
    11631171      friend class GraphWrapper<Graph>;
    11641172      friend class stGraphWrapper<Graph>;
    1165       template <typename T> friend class EdgeMap;
     1173      template <typename T, typename Parent> friend class EdgeMap;
    11661174      int spec;
    11671175      typename Graph::Node n;
     
    11851193                u.n!=v.n);
    11861194      }
     1195      friend std::ostream& operator<<(std::ostream& os, const Edge& i);
    11871196      int getSpec() const { return spec; }
    11881197    };
     1198
    11891199    class OutEdgeIt {
    11901200      friend class GraphWrapper<Graph>;
     
    12301240      operator Edge() const { return Edge(e, spec, n); }
    12311241    };
     1242
    12321243    class InEdgeIt {
    12331244      friend class GraphWrapper<Graph>;
     
    12621273            spec=3;
    12631274            n=INVALID;
     1275            break;
    12641276          case 2:
    12651277            e=INVALID;
    1266             spec=1;
     1278            spec=2;
    12671279            _G.graph->first(n, T_CLASS); //vmi->t;
    12681280            if (!_G.graph->valid(n)) spec=3; //Ha T ures
     
    12721284      operator Edge() const { return Edge(e, spec, n); }
    12731285    };
     1286
    12741287    class EdgeIt {
    12751288      friend class GraphWrapper<Graph>;
     
    13351348      switch (i.spec) {
    13361349        case 0: //normal edge
    1337           this->graph->aNode(i.e);
     1350          v=this->graph->aNode(i.e);
    13381351          this->graph->next(i.e);
    13391352          if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
     
    14481461    bool valid(const Edge& e) const { return (e.spec<3); }
    14491462
    1450 //    int nodeNum() const { return this->graph->nodeNum(); }
    1451 //    int edgeNum() const { return this->graph->edgeNum(); }
     1463    int nodeNum() const { return this->graph->nodeNum()+2; }
     1464    int edgeNum() const {
     1465      return this->graph->edgeNum()+this->graph->nodeNum();
     1466    }
    14521467 
    14531468    Node aNode(const OutEdgeIt& e) const { return tail(e); }
     
    14551470    Node bNode(const OutEdgeIt& e) const { return head(e); }
    14561471    Node bNode(const InEdgeIt& e) const { return tail(e); }
    1457  
     1472
     1473    void addNode() const { }
     1474    void addEdge() const { }
     1475   
    14581476//    Node addNode() const { return Node(this->graph->addNode()); }
    14591477//    Edge addEdge(const Node& tail, const Node& head) const {
     
    14691487      T s_value, t_value;
    14701488    public:
    1471       NodeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G) { }
     1489      NodeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G),
     1490                                                  s_value(),
     1491                                                  t_value() { }
    14721492      NodeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a),
    14731493                                                      s_value(a),
     
    15031523    };
    15041524
    1505     template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> {
    1506       typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
     1525    template<typename T,
     1526             typename Parent=
     1527             typename GraphWrapper<Graph>::template EdgeMap<T> >
     1528    class EdgeMap : public Parent {
     1529      //typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
    15071530      typename GraphWrapper<Graph>::template NodeMap<T> node_value;
    15081531    public:
     
    15281551        switch (e.spec) {
    15291552        case 0:
    1530           GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
     1553          Parent::set(e, t);
    15311554          break;
    15321555        case 1:
     
    15401563      }
    15411564    };
     1565
     1566//     template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> {
     1567//       typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
     1568//       typename GraphWrapper<Graph>::template NodeMap<T> node_value;
     1569//     public:
     1570//       EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G),
     1571//                                               node_value(_G) { }
     1572//       EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a),
     1573//                                                    node_value(_G, a) { }
     1574//       T operator[](const Edge& e) const {
     1575//      switch (e.spec) {
     1576//      case 0:
     1577//        return Parent::operator[](e);
     1578//        break;
     1579//      case 1:
     1580//        return node_value[e.n];
     1581//        break;
     1582//      case 2:
     1583//      default:
     1584//        return node_value[e.n];
     1585//        break;
     1586//      }
     1587//       }
     1588//       void set(const Edge& e, T t) {
     1589//      switch (e.spec) {
     1590//      case 0:
     1591//        GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
     1592//        break;
     1593//      case 1:
     1594//        node_value.set(e.n, t);
     1595//        break;
     1596//      case 2:
     1597//      default:
     1598//        node_value.set(e.n, t);
     1599//        break;
     1600//      }
     1601//       }
     1602//     };
     1603
     1604    friend std::ostream& operator<<(std::ostream& os, const Node& i) {
     1605      os << "(node: " << typename Graph::Node(i) << " spec: " << i.spec <<")";
     1606      return os;
     1607    }
     1608    friend std::ostream& operator<<(std::ostream& os, const Edge& i) {
     1609      os << "(edge: " << typename Graph::Edge(i) << " spec: " << i.spec <<
     1610        " node: " << i.n << ")";
     1611      return os;
     1612    }
     1613
    15421614  };
    15431615
Note: See TracChangeset for help on using the changeset viewer.