src/work/alpar/list_graph.h
changeset 538 d8863141824d
parent 515 a7eeb8af6b34
child 542 69bde1d90c04
equal deleted inserted replaced
11:6d525f945695 12:505505cdaa22
   470 	return *this;
   470 	return *this;
   471       }
   471       }
   472       template<typename TT>
   472       template<typename TT>
   473       const NodeMap<T>& operator=(const NodeMap<TT> &m)
   473       const NodeMap<T>& operator=(const NodeMap<TT> &m)
   474       {
   474       {
   475 	copy(m.container.begin(), m.container.end(), container.begin());
   475 	std::copy(m.container.begin(), m.container.end(), container.begin());
   476 	return *this;
   476 	return *this;
   477       }
   477       }
   478       
   478       
   479       void update() {}    //Useless for Dynamic Maps
   479       void update() {}    //Useless for Dynamic Maps
   480       void update(T a) {}  //Useless for Dynamic Maps
   480       void update(T a) {}  //Useless for Dynamic Maps
   559 	return *this;
   559 	return *this;
   560       }
   560       }
   561       template<typename TT>
   561       template<typename TT>
   562       const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
   562       const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
   563       {
   563       {
   564 	copy(m.container.begin(), m.container.end(), container.begin());
   564 	std::copy(m.container.begin(), m.container.end(), container.begin());
   565 	return *this;
   565 	return *this;
   566       }
   566       }
   567       
   567       
   568       void update() {}    //Useless for DynMaps
   568       void update() {}    //Useless for DynMaps
   569       void update(T a) {}  //Useless for DynMaps
   569       void update(T a) {}  //Useless for DynMaps
   713 	return *this;
   713 	return *this;
   714       }
   714       }
   715       template<typename TT>
   715       template<typename TT>
   716       const SymEdgeMap<T>& operator=(const SymEdgeMap<TT> &m)
   716       const SymEdgeMap<T>& operator=(const SymEdgeMap<TT> &m)
   717       {
   717       {
   718 	copy(m.container.begin(), m.container.end(), container.begin());
   718 	std::copy(m.container.begin(), m.container.end(), container.begin());
   719 	return *this;
   719 	return *this;
   720       }
   720       }
   721       
   721       
   722       void update() {}    //Useless for DynMaps
   722       void update() {}    //Useless for DynMaps
   723       void update(T a) {}  //Useless for DynMaps
   723       void update(T a) {}  //Useless for DynMaps
  1079 	return *this;
  1079 	return *this;
  1080       }
  1080       }
  1081       template<typename TT>
  1081       template<typename TT>
  1082       const NodeMap<T>& operator=(const NodeMap<TT> &m)
  1082       const NodeMap<T>& operator=(const NodeMap<TT> &m)
  1083       {
  1083       {
  1084 	copy(m.container.begin(), m.container.end(), container.begin());
  1084 	std::copy(m.container.begin(), m.container.end(), container.begin());
  1085 	return *this;
  1085 	return *this;
  1086       }
  1086       }
  1087       
  1087       
  1088       void update() {}    //Useless for Dynamic Maps
  1088       void update() {}    //Useless for Dynamic Maps
  1089       void update(T a) {}  //Useless for Dynamic Maps
  1089       void update(T a) {}  //Useless for Dynamic Maps
  1152 
  1152 
  1153     NodeGraphType &G;
  1153     NodeGraphType &G;
  1154 
  1154 
  1155   public:
  1155   public:
  1156     class Node;
  1156     class Node;
       
  1157     int id(Node v) const; 
       
  1158 
       
  1159     class Node : public NodeGraphType::Node {
       
  1160       friend class EdgeSet;
       
  1161       //      template <typename T> friend class NodeMap;
       
  1162       
       
  1163       friend class Edge;
       
  1164       friend class OutEdgeIt;
       
  1165       friend class InEdgeIt;
       
  1166       friend class SymEdge;
       
  1167 
       
  1168     public:
       
  1169       friend int EdgeSet::id(Node v) const; 
       
  1170       //      Node(int nn) {n=nn;}
       
  1171     public:
       
  1172       Node() : NodeGraphType::Node() {}
       
  1173       Node (Invalid i) : NodeGraphType::Node(i) {}
       
  1174       Node(const typename NodeGraphType::Node &n) : NodeGraphType::Node(n) {}
       
  1175     };
       
  1176     
       
  1177     class NodeIt : public NodeGraphType::NodeIt {
       
  1178       friend class EdgeSet;
       
  1179     public:
       
  1180       NodeIt() : NodeGraphType::NodeIt() { }
       
  1181       NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
       
  1182       NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
       
  1183       NodeIt(const typename NodeGraphType::NodeIt &n)
       
  1184 	: NodeGraphType::NodeIt(n) {}
       
  1185       operator Node() { return Node(*this);}
       
  1186     };
  1157 
  1187 
  1158   private:
  1188   private:
  1159     //Edges are double linked.
  1189     //Edges are double linked.
  1160     //The free edges are only single linked using the "next_in" field.
  1190     //The free edges are only single linked using the "next_in" field.
  1161     struct NodeT 
  1191     struct NodeT 
  1303 	it.n = (valid(n))?-1:nodes[n].first_in;
  1333 	it.n = (valid(n))?-1:nodes[n].first_in;
  1304       }
  1334       }
  1305       return it;
  1335       return it;
  1306     }
  1336     }
  1307 
  1337 
  1308     int id(Node v) const { return G.id(v); }
       
  1309     int id(Edge e) const { return e.n; }
  1338     int id(Edge e) const { return e.n; }
  1310 
  1339 
  1311     /// Adds a new node to the graph.
  1340     /// Adds a new node to the graph.
  1312     Node addNode() { return G.AddNode(); }
  1341     Node addNode() { return G.AddNode(); }
  1313     
  1342     
  1384 //     //
  1413 //     //
  1385 //     void clear() {
  1414 //     void clear() {
  1386 //       nodes.clear();edges.clear();
  1415 //       nodes.clear();edges.clear();
  1387 //       first_node=first_free_node=first_free_edge=-1;
  1416 //       first_node=first_free_node=first_free_edge=-1;
  1388 //     }
  1417 //     }
  1389 
       
  1390   public:
       
  1391     class Node : public NodeGraphType::Node {
       
  1392       friend class EdgeSet;
       
  1393       //      template <typename T> friend class NodeMap;
       
  1394       
       
  1395       friend class Edge;
       
  1396       friend class OutEdgeIt;
       
  1397       friend class InEdgeIt;
       
  1398       friend class SymEdge;
       
  1399 
       
  1400     protected:
       
  1401       friend int EdgeSet::id(Node v) const; 
       
  1402       //      Node(int nn) {n=nn;}
       
  1403     public:
       
  1404       Node() : NodeGraphType::Node() {}
       
  1405       Node (Invalid i) : NodeGraphType::Node(i) {}
       
  1406       Node(const typename NodeGraphType::Node &n) : NodeGraphType::Node(n) {}
       
  1407     };
       
  1408     
       
  1409     class NodeIt : public NodeGraphType::NodeIt {
       
  1410       friend class EdgeSet;
       
  1411     public:
       
  1412       NodeIt() : NodeGraphType::NodeIt() { }
       
  1413       NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
       
  1414       NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
       
  1415       NodeIt(const typename NodeGraphType::NodeIt &n)
       
  1416 	: NodeGraphType::NodeIt(n) {}
       
  1417       operator Node() { return Node(*this);}
       
  1418     };
       
  1419 
  1418 
  1420     class Edge {
  1419     class Edge {
  1421       friend class EdgeSet;
  1420       friend class EdgeSet;
  1422       template <typename T> friend class EdgeMap;
  1421       template <typename T> friend class EdgeMap;
  1423 
  1422 
  1576 	return *this;
  1575 	return *this;
  1577       }
  1576       }
  1578       template<typename TT>
  1577       template<typename TT>
  1579       const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
  1578       const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
  1580       {
  1579       {
  1581 	copy(m.container.begin(), m.container.end(), container.begin());
  1580 	std::copy(m.container.begin(), m.container.end(), container.begin());
  1582 	return *this;
  1581 	return *this;
  1583       }
  1582       }
  1584       
  1583       
  1585       void update() {}    //Useless for DynMaps
  1584       void update() {}    //Useless for DynMaps
  1586       void update(T a) {}  //Useless for DynMaps
  1585       void update(T a) {}  //Useless for DynMaps
  1587     };
  1586     };
  1588 
  1587 
  1589   };
  1588   };
  1590 
  1589 
       
  1590   template< typename GG>
       
  1591   int EdgeSet<GG>::id(Node v) const { return G.id(v); }
       
  1592 
  1591 /// @}  
  1593 /// @}  
  1592 
  1594 
  1593 } //namespace hugo
  1595 } //namespace hugo
  1594 
  1596 
  1595 #endif //HUGO_LIST_GRAPH_H
  1597 #endif //HUGO_LIST_GRAPH_H