Changeset 409:7ab7f083760a in lemon-0.x for src/work/marci/graph_wrapper.h
- Timestamp:
- 04/26/04 11:54:24 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@542
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/graph_wrapper.h
r406 r409 924 924 925 925 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; 928 930 931 bool S_CLASS; 932 bool T_CLASS; 933 929 934 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) { } 932 937 typedef typename GraphWrapper<Graph>::Node Node; 933 938 //using GraphWrapper<Graph>::NodeIt; … … 1103 1108 //invalid, 3, invalid) 1104 1109 template <typename T> class NodeMap; 1105 template <typename T > class EdgeMap;1110 template <typename T, typename Parent> class EdgeMap; 1106 1111 1107 1112 // template <typename T> friend class NodeMap; … … 1142 1147 static_cast<typename Graph::Node>(u)!= 1143 1148 static_cast<typename Graph::Node>(v)); 1144 } 1149 } 1150 friend std::ostream& operator<<(std::ostream& os, const Node& i); 1145 1151 int getSpec() const { return spec; } 1146 1152 }; 1153 1147 1154 class NodeIt { 1148 1155 friend class GraphWrapper<Graph>; … … 1156 1163 NodeIt(const Invalid& i) : n(i), spec(3) { } 1157 1164 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; 1159 1166 } 1160 1167 operator Node() const { return Node(n, spec); } 1161 1168 }; 1169 1162 1170 class Edge : public Graph::Edge { 1163 1171 friend class GraphWrapper<Graph>; 1164 1172 friend class stGraphWrapper<Graph>; 1165 template <typename T > friend class EdgeMap;1173 template <typename T, typename Parent> friend class EdgeMap; 1166 1174 int spec; 1167 1175 typename Graph::Node n; … … 1185 1193 u.n!=v.n); 1186 1194 } 1195 friend std::ostream& operator<<(std::ostream& os, const Edge& i); 1187 1196 int getSpec() const { return spec; } 1188 1197 }; 1198 1189 1199 class OutEdgeIt { 1190 1200 friend class GraphWrapper<Graph>; … … 1230 1240 operator Edge() const { return Edge(e, spec, n); } 1231 1241 }; 1242 1232 1243 class InEdgeIt { 1233 1244 friend class GraphWrapper<Graph>; … … 1262 1273 spec=3; 1263 1274 n=INVALID; 1275 break; 1264 1276 case 2: 1265 1277 e=INVALID; 1266 spec= 1;1278 spec=2; 1267 1279 _G.graph->first(n, T_CLASS); //vmi->t; 1268 1280 if (!_G.graph->valid(n)) spec=3; //Ha T ures … … 1272 1284 operator Edge() const { return Edge(e, spec, n); } 1273 1285 }; 1286 1274 1287 class EdgeIt { 1275 1288 friend class GraphWrapper<Graph>; … … 1335 1348 switch (i.spec) { 1336 1349 case 0: //normal edge 1337 this->graph->aNode(i.e);1350 v=this->graph->aNode(i.e); 1338 1351 this->graph->next(i.e); 1339 1352 if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk … … 1448 1461 bool valid(const Edge& e) const { return (e.spec<3); } 1449 1462 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 } 1452 1467 1453 1468 Node aNode(const OutEdgeIt& e) const { return tail(e); } … … 1455 1470 Node bNode(const OutEdgeIt& e) const { return head(e); } 1456 1471 Node bNode(const InEdgeIt& e) const { return tail(e); } 1457 1472 1473 void addNode() const { } 1474 void addEdge() const { } 1475 1458 1476 // Node addNode() const { return Node(this->graph->addNode()); } 1459 1477 // Edge addEdge(const Node& tail, const Node& head) const { … … 1469 1487 T s_value, t_value; 1470 1488 public: 1471 NodeMap(const stGraphWrapper<Graph>& _G) : Parent(_G) { } 1489 NodeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 1490 s_value(), 1491 t_value() { } 1472 1492 NodeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 1473 1493 s_value(a), … … 1503 1523 }; 1504 1524 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; 1507 1530 typename GraphWrapper<Graph>::template NodeMap<T> node_value; 1508 1531 public: … … 1528 1551 switch (e.spec) { 1529 1552 case 0: 1530 GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);1553 Parent::set(e, t); 1531 1554 break; 1532 1555 case 1: … … 1540 1563 } 1541 1564 }; 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 1542 1614 }; 1543 1615
Note: See TracChangeset
for help on using the changeset viewer.