src/work/list_graph.h
changeset 304 10d035c2e81c
parent 279 be43902fadb7
child 309 50f1d2077d50
equal deleted inserted replaced
7:a97ad3a9871c 8:c8cf3f683c94
    42       typedef Node KeyType;
    42       typedef Node KeyType;
    43       NodeMap(const ListGraph& _G) : G(_G), container(G.node_id) { }
    43       NodeMap(const ListGraph& _G) : G(_G), container(G.node_id) { }
    44       NodeMap(const ListGraph& _G, T a) : 
    44       NodeMap(const ListGraph& _G, T a) : 
    45 	G(_G), container(G.node_id, a) { }
    45 	G(_G), container(G.node_id, a) { }
    46       void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; }
    46       void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; }
    47       T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }
    47 //      T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }
    48       typename std::vector<T>::reference operator[](Node n) { 
    48       typename std::vector<T>::reference operator[](Node n) { 
    49 	return container[/*G.id(n)*/n.node->id]; }
    49 	return container[/*G.id(n)*/n.node->id]; }
    50       typename std::vector<T>::const_reference operator[](Node n) const { 
    50       typename std::vector<T>::const_reference operator[](Node n) const { 
    51 	return container[/*G.id(n)*/n.node->id]; 
    51 	return container[/*G.id(n)*/n.node->id]; 
    52       }
    52       }
    63       typedef Edge KeyType;
    63       typedef Edge KeyType;
    64       EdgeMap(const ListGraph& _G) : G(_G), container(G.edge_id) { }
    64       EdgeMap(const ListGraph& _G) : G(_G), container(G.edge_id) { }
    65       EdgeMap(const ListGraph& _G, T a) : 
    65       EdgeMap(const ListGraph& _G, T a) : 
    66 	G(_G), container(G.edge_id, a) { }
    66 	G(_G), container(G.edge_id, a) { }
    67       void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; }
    67       void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; }
    68       T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }
    68 //      T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }
    69       typename std::vector<T>::reference operator[](Edge e) { 
    69       typename std::vector<T>::reference operator[](Edge e) { 
    70 	return container[/*G.id(e)*/e.edge->id]; } 
    70 	return container[/*G.id(e)*/e.edge->id]; } 
    71       typename std::vector<T>::const_reference operator[](Edge e) const { 
    71       typename std::vector<T>::const_reference operator[](Edge e) const { 
    72 	return container[/*G.id(e)*/e.edge->id]; 
    72 	return container[/*G.id(e)*/e.edge->id]; 
    73       } 
    73       } 
   265     //SymEdgeIt invalid_sym_edge() { return SymEdgeIt(); }
   265     //SymEdgeIt invalid_sym_edge() { return SymEdgeIt(); }
   266 
   266 
   267     /* same methods in other style */
   267     /* same methods in other style */
   268     /* for experimental purpose */
   268     /* for experimental purpose */
   269 
   269 
   270     NodeIt& /*getF*/first(NodeIt& v) const { 
   270     NodeIt& first(NodeIt& v) const { 
   271       v=NodeIt(*this); return v; }
   271       v=NodeIt(*this); return v; }
   272     EdgeIt& /*getF*/first(EdgeIt& e) const { 
   272     EdgeIt& first(EdgeIt& e) const { 
   273       e=EdgeIt(*this); return e; }
   273       e=EdgeIt(*this); return e; }
   274     OutEdgeIt& /*getF*/first(OutEdgeIt& e, Node v) const { 
   274     OutEdgeIt& first(OutEdgeIt& e, Node v) const { 
   275       e=OutEdgeIt(*this, v); return e; }
   275       e=OutEdgeIt(*this, v); return e; }
   276     InEdgeIt& /*getF*/first(InEdgeIt& e, Node v) const { 
   276     InEdgeIt& first(InEdgeIt& e, Node v) const { 
   277       e=InEdgeIt(*this, v); return e; }
   277       e=InEdgeIt(*this, v); return e; }
   278     SymEdgeIt& /*getF*/first(SymEdgeIt& e, Node v) const { 
   278     SymEdgeIt& first(SymEdgeIt& e, Node v) const { 
   279       e=SymEdgeIt(*this, v); return e; }
   279       e=SymEdgeIt(*this, v); return e; }
   280     //void getTail(Node& n, const Edge& e) const { n=tail(e); }
   280     //void getTail(Node& n, const Edge& e) const { n=tail(e); }
   281     //void getHead(Node& n, const Edge& e) const { n=head(e); }
   281     //void getHead(Node& n, const Edge& e) const { n=head(e); }
   282 
   282 
   283     //void getANode(Node& n, const OutEdgeIt& e) const { n=e.aNode(); }
   283     //void getANode(Node& n, const OutEdgeIt& e) const { n=e.aNode(); }
   293     //void get_invalid(SymEdgeIt& e) { e=SymEdgeIt(); }
   293     //void get_invalid(SymEdgeIt& e) { e=SymEdgeIt(); }
   294 
   294 
   295     template< typename It >
   295     template< typename It >
   296     It first() const { 
   296     It first() const { 
   297       It e;
   297       It e;
   298       /*getF*/first(e);
   298       first(e);
   299       return e; 
   299       return e; 
   300     }
   300     }
   301 
   301 
   302     template< typename It >
   302     template< typename It >
   303     It first(Node v) const { 
   303     It first(Node v) const { 
   304       It e;
   304       It e;
   305       /*getF*/first(e, v);
   305       first(e, v);
   306       return e; 
   306       return e; 
   307     }
   307     }
   308 
   308 
   309     bool valid(Node n) const { return n.valid(); }
   309     bool valid(Node n) const { return n.valid(); }
   310     bool valid(Edge e) const { return e.valid(); }
   310     bool valid(Edge e) const { return e.valid(); }