47 G(_G), container(G.node_id, a) { } |
47 G(_G), container(G.node_id, a) { } |
48 void set(NodeIt n, T a) { container[/*G.id(n)*/n.node->id]=a; } |
48 void set(NodeIt n, T a) { container[/*G.id(n)*/n.node->id]=a; } |
49 T get(NodeIt n) const { return container[/*G.id(n)*/n.node->id]; } |
49 T get(NodeIt n) const { return container[/*G.id(n)*/n.node->id]; } |
50 T& operator[](NodeIt n) { return container[/*G.id(n)*/n.node->id]; } |
50 T& operator[](NodeIt n) { return container[/*G.id(n)*/n.node->id]; } |
51 const T& operator[](NodeIt n) const { return container[/*G.id(n)*/n.node->id]; } |
51 const T& operator[](NodeIt n) const { return container[/*G.id(n)*/n.node->id]; } |
52 void resize() { container.resize(G.node_id); } |
52 void update() { container.resize(G.node_id); } |
53 void resize(T a) { container.resize(G.node_id, a); } |
53 void update(T a) { container.resize(G.node_id, a); } |
54 }; |
54 }; |
55 |
55 |
56 template <typename T> |
56 template <typename T> |
57 class EdgeMap { |
57 class EdgeMap { |
58 const ListGraph& G; |
58 const ListGraph& G; |
65 G(_G), container(G.edge_id, a) { } |
65 G(_G), container(G.edge_id, a) { } |
66 void set(EdgeIt e, T a) { container[/*G.id(e)*/e.edge->id]=a; } |
66 void set(EdgeIt e, T a) { container[/*G.id(e)*/e.edge->id]=a; } |
67 T get(EdgeIt e) const { return container[/*G.id(e)*/e.edge->id]; } |
67 T get(EdgeIt e) const { return container[/*G.id(e)*/e.edge->id]; } |
68 T& operator[](EdgeIt e) { return container[/*G.id(e)*/e.edge->id]; } |
68 T& operator[](EdgeIt e) { return container[/*G.id(e)*/e.edge->id]; } |
69 const T& operator[](EdgeIt e) const { return container[/*G.id(e)*/e.edge->id]; } |
69 const T& operator[](EdgeIt e) const { return container[/*G.id(e)*/e.edge->id]; } |
70 void resize() { container.resize(G.edge_id); } |
70 void update() { container.resize(G.edge_id); } |
71 void resize(T a) { container.resize(G.edge_id, a); } |
71 void update(T a) { container.resize(G.edge_id, a); } |
72 }; |
72 }; |
73 |
73 |
74 int node_id; |
74 int node_id; |
75 int edge_id; |
75 int edge_id; |
76 int _node_num; |
76 int _node_num; |
304 |
304 |
305 bool valid(EdgeIt e) const { return e.valid(); } |
305 bool valid(EdgeIt e) const { return e.valid(); } |
306 bool valid(NodeIt n) const { return n.valid(); } |
306 bool valid(NodeIt n) const { return n.valid(); } |
307 |
307 |
308 template <typename It> It next(It it) const { |
308 template <typename It> It next(It it) const { |
309 It tmp(it); return goNext(it); } |
309 It tmp(it); return goNext(tmp); } |
310 template <typename It> It& goNext(It& it) const { return ++it; } |
310 template <typename It> It& goNext(It& it) const { return ++it; } |
311 |
311 |
312 |
312 |
313 /* for getting id's of graph objects */ |
313 /* for getting id's of graph objects */ |
314 /* these are important for the implementation of property vectors */ |
314 /* these are important for the implementation of property vectors */ |
506 return (out_or_in) ? NodeIt(edge->_head) : NodeIt(edge->_tail); } |
506 return (out_or_in) ? NodeIt(edge->_head) : NodeIt(edge->_tail); } |
507 }; |
507 }; |
508 |
508 |
509 }; |
509 }; |
510 |
510 |
511 /* |
511 // template< typename T > |
512 template< typename T > |
512 // T ListGraph::first() const { |
513 T ListGraph::first() const { |
513 // std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>();" << std::endl; |
514 std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>();" << std::endl; |
514 // return T(); |
515 return T(); |
515 // } |
516 } |
516 |
517 |
517 // template<> |
518 template<> |
518 // ListGraph::EachNodeIt ListGraph::first<ListGraph::EachNodeIt>() const { |
519 ListGraph::EachNodeIt ListGraph::first<ListGraph::EachNodeIt>() const { |
519 // return firstNode(); |
520 return firstNode(); |
520 // } |
521 } |
521 |
522 |
522 // template<> |
523 template<> |
523 // ListGraph::EachEdgeIt ListGraph::first<ListGraph::EachEdgeIt>() const { |
524 ListGraph::EachEdgeIt ListGraph::first<ListGraph::EachEdgeIt>() const { |
524 // return firstEdge(); |
525 return firstEdge(); |
525 // } |
526 } |
526 |
527 |
527 // template< typename T > |
528 template< typename T > |
528 // T ListGraph::first(ListGraph::NodeIt v) const { |
529 T ListGraph::first(ListGraph::NodeIt v) const { |
529 // std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>(ListGRaph::NodeIt);" << std::endl; |
530 std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>(ListGRaph::NodeIt);" << std::endl; |
530 // return T(); |
531 return T(); |
531 // } |
532 } |
532 |
533 |
533 // template<> |
534 template<> |
534 // ListGraph::OutEdgeIt ListGraph::first<ListGraph::OutEdgeIt>(const ListGraph::NodeIt v) const { |
535 ListGraph::OutEdgeIt ListGraph::first<ListGraph::OutEdgeIt>(const ListGraph::NodeIt v) const { |
535 // return firstOutEdge(v); |
536 return firstOutEdge(v); |
536 // } |
537 } |
537 |
538 |
538 // template<> |
539 template<> |
539 // ListGraph::InEdgeIt ListGraph::first<ListGraph::InEdgeIt>(const ListGraph::NodeIt v) const { |
540 ListGraph::InEdgeIt ListGraph::first<ListGraph::InEdgeIt>(const ListGraph::NodeIt v) const { |
540 // return firstInEdge(v); |
541 return firstInEdge(v); |
541 // } |
542 } |
542 |
543 |
543 // template<> |
544 template<> |
544 // ListGraph::SymEdgeIt ListGraph::first<ListGraph::SymEdgeIt>(const ListGraph::NodeIt v) const { |
545 ListGraph::SymEdgeIt ListGraph::first<ListGraph::SymEdgeIt>(const ListGraph::NodeIt v) const { |
545 // return firstSymEdge(v); |
546 return firstSymEdge(v); |
546 // } |
547 } |
547 |
548 */ |
548 |
549 |
549 } //namespace hugo |
550 |
|
551 } //namespace marci |
|
552 |
550 |
553 #endif //LIST_GRAPH_HH |
551 #endif //LIST_GRAPH_HH |