Changeset 579:859f8c7e2a40 in lemon0.x
 Timestamp:
 05/07/04 17:58:45 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@755
 Location:
 src
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

src/hugo/list_graph.h
r578 r579 95 95 class InEdgeIt; 96 96 97 template <typename T> class NodeMap;98 template <typename T> class EdgeMap;99 100 97 public: 101 98 … … 329 326 NodeIt(Invalid i) : Node(i) { } 330 327 NodeIt(const ListGraph& G) : Node(G.first_node) { } 328 ///\todo Undocumented conversion Node \> NodeIt. 329 NodeIt(const ListGraph& G, const Node &n) : Node(n) { } 331 330 }; 332 331 … … 483 482 template <typename T> class EdgeMap : public DynMapBase<Edge> 484 483 { 484 protected: 485 485 std::vector<T> container; 486 486 … … 945 945 friend class NodeSet; 946 946 public: 947 NodeIt() : Node() { } 948 NodeIt(Invalid i) : Node(i) { } 947 949 NodeIt(const NodeSet& G) : Node(G.first_node) { } 948 NodeIt() : Node() { } 950 ///\todo Undocumented conversion Node \> NodeIt. 951 NodeIt(const NodeSet& G, const Node &n) : Node(n) { } 952 949 953 }; 950 954 … … 1183 1187 NodeIt(const typename NodeGraphType::NodeIt &n) 1184 1188 : NodeGraphType::NodeIt(n) {} 1189 ///\todo Undocumented conversion Node \> NodeIt. 1190 NodeIt(const EdgeSet& _G, const Node &n) 1191 : NodeGraphType::NodeIt(_G.G,n) { } 1192 1185 1193 operator Node() { return Node(*this);} 1186 1194 }; … … 1327 1335 } 1328 1336 else { 1329 NodeIt n ;1330 for(n=next( edges[it.n].head);1337 NodeIt n(*this,edges[it.n].head); 1338 for(n=next(n); 1331 1339 valid(n) && nodes[n].first_in == 1; 1332 1340 next(n)) ; … … 1339 1347 1340 1348 /// Adds a new node to the graph. 1341 Node addNode() { return G. AddNode(); }1349 Node addNode() { return G.addNode(); } 1342 1350 1343 1351 Edge addEdge(Node u, Node v) { … … 1410 1418 void erase(Edge e) { eraseEdge(e.n); } 1411 1419 1420 ///Clear all edges. (Doesn't clear the nodes!) 1421 void clear() { 1422 edges.clear(); 1423 first_free_edge=1; 1424 } 1425 1426 1412 1427 // //\bug Dynamic maps must be updated! 1413 1428 // // … … 1417 1432 // } 1418 1433 1434 public: 1435 template <typename T> class EdgeMap; 1436 1437 /// 1419 1438 class Edge { 1439 public: 1420 1440 friend class EdgeSet; 1421 1441 template <typename T> friend class EdgeMap; 1422 1442 1423 //template <typename T> friend class SymEdgeSet::SymEdgeMap;1424 //friend Edge SymEdgeSet::opposite(Edge) const;1425 1426 1443 friend class Node; 1427 1444 friend class NodeIt; 1445 public: 1446 ///\bug It shoud be at least protected 1447 /// 1448 int n; 1428 1449 protected: 1429 int n;1430 1450 friend int EdgeSet::id(Edge e) const; 1431 1451 … … 1445 1465 class EdgeIt : public Edge { 1446 1466 friend class EdgeSet; 1467 template <typename T> friend class EdgeMap; 1468 1469 1447 1470 public: 1448 1471 EdgeIt(const EdgeSet& G) : Edge() { … … 1467 1490 OutEdgeIt (Invalid i) : Edge(i) { } 1468 1491 1469 OutEdgeIt(const EdgeSet& G,const Node v) : Edge( nodes[v].first_out) { }1492 OutEdgeIt(const EdgeSet& G,const Node v) : Edge(G.nodes[v].first_out) { } 1470 1493 }; 1471 1494 … … 1475 1498 InEdgeIt() : Edge() { } 1476 1499 InEdgeIt (Invalid i) : Edge(i) { } 1477 InEdgeIt(const EdgeSet& G,Node v) :Edge( nodes[v].first_in) { }1500 InEdgeIt(const EdgeSet& G,Node v) :Edge(G.nodes[v].first_in) { } 1478 1501 }; 1479 1502 … … 1481 1504 public NodeGraphType::template NodeMap<T> 1482 1505 { 1483 public:1484 NodeMap(const EdgeSet &_G) :1485 NodeGraphType::NodeMap(_G.G) { } //AJAJJ <T> would be wrong!!!1486 NodeMap(const EdgeSet &_G ,const T &t) :1487 NodeGraphType::NodeMap(_G.G,t) { }1506 //This is a must, the constructors need it. 1507 typedef typename NodeGraphType::template NodeMap<T> ParentNodeMap; 1508 public: 1509 NodeMap(const EdgeSet &_G) : ParentNodeMap(_G.G) { } 1510 NodeMap(const EdgeSet &_G,const T &t) : ParentNodeMap(_G.G,t) { } 1488 1511 //It is unnecessary 1489 1512 NodeMap(const typename NodeGraphType::template NodeMap<T> &m) : 1490 NodeGraphType::NodeMap(m) { }1513 ParentNodeMap(m) { } 1491 1514 1492 1515 ///\todo It can copy between different types. … … 1494 1517 template<typename TT> 1495 1518 NodeMap(const typename NodeGraphType::template NodeMap<TT> &m) 1496 : NodeGraphType::NodeMap(m) { } 1497 }; 1498 1519 : ParentNodeMap(m) { } 1520 }; 1521 1522 /// 1499 1523 template <typename T> class EdgeMap : public DynMapBase<Edge> 1500 1524 { 1525 protected: 1526 public: 1527 ///\bug It should be at least protected 1528 /// 1501 1529 std::vector<T> container; 1502 1530 … … 1558 1586 void erase(const Edge) { } 1559 1587 1560 void set(Edge n, T a) { container[n.n]=a; } 1588 ///\bug This doesn't work. Why? 1589 /// void set(Edge n, T a) { container[n.n]=a; } 1590 void set(Edge n, T a) { container[G>id(n)]=a; } 1561 1591 //T get(Edge n) const { return container[n.n]; } 1562 1592 typename std::vector<T>::reference 1563 operator[](Edge n) { return container[n.n]; } 1593 ///\bug This doesn't work. Why? 1594 /// operator[](Edge n) { return container[n.n]; } 1595 operator[](Edge n) { return container[G>id(n)]; } 1564 1596 typename std::vector<T>::const_reference 1565 operator[](Edge n) const { return container[n.n]; } 1597 ///\bug This doesn't work. Why? 1598 /// operator[](Edge n) const { return container[n.n]; } 1599 operator[](Edge n) const { return container[G>id(n)]; } 1566 1600 1567 1601 ///\warning There is no safety check at all! … … 1575 1609 return *this; 1576 1610 } 1611 1612 template<typename TT> friend class EdgeMap; 1613 1577 1614 template<typename TT> 1578 1615 const EdgeMap<T>& operator=(const EdgeMap<TT> &m) … … 1588 1625 }; 1589 1626 1590 template< 1591 in t EdgeSet<GG>::id(Node v) const { return G.id(v); }1627 template<typename GG> 1628 inline int EdgeSet<GG>::id(Node v) const { return G.id(v); } 1592 1629 1593 1630 /// @} 
src/hugo/smart_graph.h
r542 r579 221 221 NodeIt(Invalid i) : Node(i) { } 222 222 NodeIt(const SmartGraph& G) : Node(G.nodes.size()?0:1) { } 223 ///\todo Undocumented conversion Node \> NodeIt. 224 NodeIt(const SmartGraph& G, const Node &n) : Node(n) { } 223 225 }; 224 226 
src/test/graph_test.cc
r578 r579 246 246 template void checkCompile<SymListGraph>(SymListGraph &); 247 247 248 //Due to some mysterious and some conceptual problems it does not work. 249 //template void checkCompile<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &); 248 //Due to some mysterious problems it does not work. 249 template void checkCompile<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &); 250 //template void checkCompile<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &); 250 251 251 252 int main() … … 279 280 std::cout << __FILE__ ": All tests passed.\n"; 280 281 281 } 282 return 0; 283 }
Note: See TracChangeset
for help on using the changeset viewer.