src/work/marci/graph_wrapper.h
changeset 341 6046b1d0f267
parent 338 e8725f30dd98
child 344 9b24714c3b1c
equal deleted inserted replaced
35:27b2c45688db 36:70c369776e80
   850       this->next(f);
   850       this->next(f);
   851       first_out_edges->set(this->tail(e), f.e);
   851       first_out_edges->set(this->tail(e), f.e);
   852     }
   852     }
   853   };
   853   };
   854 
   854 
       
   855 
       
   856 
       
   857 //   /// experimentral, do not try it.
       
   858 //   template<typename Graph>
       
   859 //   class stGraphWrapper : public GraphWrapper<Graph> {
       
   860 //   public:
       
   861 //     class Node;
       
   862 //     class NodeIt;
       
   863 //     class Edge;
       
   864 //     class OutEdgeIt;
       
   865 //     class InEdgeIt;
       
   866 //     class EdgeIt;
       
   867 
       
   868 //     const Node s;
       
   869 //     const Node t;
       
   870 
       
   871 //     stGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph), 
       
   872 // 				    s(INVALID, 1), t(INVALID, 2) { }
       
   873 
       
   874 //     class Node : public Graph::Node {
       
   875 //       friend class GraphWrapper<Graph>;
       
   876 //       friend class stGraphWrapper<Graph>;
       
   877 //     protected:
       
   878 //       int spec; //0 if real node, 1 iff s, 2 iff t
       
   879 //     public:
       
   880 //       Node() { }
       
   881 //       Node(const typename Graph::Node& _n, int _spec=0) : 
       
   882 // 	Graph::Node(_n), spec(_spec) { }
       
   883 //       Node(const Invalid& i) : Graph::Node(i), spec(2) { }
       
   884 //       //invalid: (invalid, 2);
       
   885 //     };
       
   886 
       
   887 //     class NodeIt { 
       
   888 //       friend class GraphWrapper<Graph>;
       
   889 //       friend class stGraphWrapper<Graph>;
       
   890 //       typename Graph::NodeIt n;
       
   891 //       int spec; 
       
   892 //      public:
       
   893 //       NodeIt() { }
       
   894 //       NodeIt(const typename Graph::NodeIt& _n, int _spec=0) : 
       
   895 // 	n(_n), spec(_spec) { }
       
   896 //       NodeIt(const Invalid& i) : n(i), spec(2) { }
       
   897 //       NodeIt(const GraphWrapper<Graph>& _G) : n(*(_G.graph)), spec(0) { 
       
   898 // 	if (!_G->valid(n)) spec=1;
       
   899 //       }
       
   900 //       operator Node() const { return Node(n, spec); }
       
   901 //     };
       
   902 // //    typedef typename Graph::Edge Edge;
       
   903 //     class Edge : public Graph::Edge {
       
   904 //       friend class GraphWrapper<Graph>;
       
   905 //       friend class stGraphWrapper<Graph>;
       
   906 //       Node tail_spec;
       
   907 //       Node head_spec;
       
   908 //     public:
       
   909 //       Edge() { }
       
   910 //       Edge(const typename Graph::Edge& _e) : 
       
   911 // 	Graph::Edge(_e), tail_spec(i, 0), head_spec(i, 0) { 
       
   912 // 	//a tail-t es a head-et real node-ra csinaljuk
       
   913 //       }
       
   914 //       Edge(const Invalid& i) : Graph::Edge(i), tail_spec(i), head_spec(i) { }
       
   915 //     };
       
   916 //     class OutEdgeIt { 
       
   917 //       friend class GraphWrapper<Graph>;
       
   918 //       friend class stGraphWrapper<Graph>;
       
   919 //       typename Graph::OutEdgeIt e;
       
   920 //       Node tail_spec;
       
   921 //       Node head_spec;
       
   922 //     public:
       
   923 //       OutEdgeIt() { }
       
   924 //       OutEdgeIt(const typename Graph::OutEdgeIt& _e) : 
       
   925 // 	e(_e), tail_spec(i, 0), head_spec(i, 0) { 
       
   926 // 	//a tail-t es a head-et real node-ra csinaljuk
       
   927 //       }
       
   928 //       OutEdgeIt(const Invalid& i) : e(i), tail_spec(i), head_spec(i) { }
       
   929 //       //invalid: (barmi, 0, 2)
       
   930 //       OutEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) {
       
   931 // 	switch (_n.spec) {
       
   932 // 	case 0 : 
       
   933 // 	  e=typename Graph::OutEdgeIt(*(_G.graph), typename Graph::Node(_n)); 
       
   934 // 	  _tail.spec=0;
       
   935 // 	  _head.spec=0;
       
   936 // 	  if (!_G.graph->valid(e)) spec=1;
       
   937 // 	  break;
       
   938 // 	case 1:
       
   939 // 	  e=INVALID;
       
   940 // 	  _tail.spec=1;
       
   941 // 	  _head(_G.graph->first(typename Graph::NodeIt()));
       
   942 // 	  if _head.spec==1
       
   943 // 	  break;
       
   944 // 	};
       
   945 	
       
   946 // 	  }
       
   947 //       operator Edge() const { return Edge(typename Graph::Edge(e)); }
       
   948 //     };
       
   949 //     class InEdgeIt { 
       
   950 //       friend class GraphWrapper<Graph>;
       
   951 //       typename Graph::InEdgeIt e;
       
   952 //     public:
       
   953 //       InEdgeIt() { }
       
   954 //       InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
       
   955 //       InEdgeIt(const Invalid& i) : e(i) { }
       
   956 //       InEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) : 
       
   957 // 	e(*(_G.graph), typename Graph::Node(_n)) { }
       
   958 //       operator Edge() const { return Edge(typename Graph::Edge(e)); }
       
   959 //     };
       
   960 //     //typedef typename Graph::SymEdgeIt SymEdgeIt;
       
   961 //     class EdgeIt { 
       
   962 //       friend class GraphWrapper<Graph>;
       
   963 //       typename Graph::EdgeIt e;
       
   964 //     public:
       
   965 //       EdgeIt() { }
       
   966 //       EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
       
   967 //       EdgeIt(const Invalid& i) : e(i) { }
       
   968 //       EdgeIt(const GraphWrapper<Graph>& _G) : e(*(_G.graph)) { }
       
   969 //       operator Edge() const { return Edge(typename Graph::Edge(e)); }
       
   970 //     };
       
   971    
       
   972 //     NodeIt& first(NodeIt& i) const { 
       
   973 //       i=NodeIt(*this); return i;
       
   974 //     }
       
   975 //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
       
   976 //       i=OutEdgeIt(*this, p); return i;
       
   977 //     }
       
   978 //     InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
       
   979 //       i=InEdgeIt(*this, p); return i;
       
   980 //     }
       
   981 //     EdgeIt& first(EdgeIt& i) const { 
       
   982 //       i=EdgeIt(*this); return i;
       
   983 //     }
       
   984 
       
   985 //     NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
       
   986 //     OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
       
   987 //     InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
       
   988 //     EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }    
       
   989 
       
   990 //     Node head(const Edge& e) const { 
       
   991 //       return Node(graph->head(static_cast<typename Graph::Edge>(e))); }
       
   992 //     Node tail(const Edge& e) const { 
       
   993 //       return Node(graph->tail(static_cast<typename Graph::Edge>(e))); }
       
   994 
       
   995 //     bool valid(const Node& n) const { 
       
   996 //       return graph->valid(static_cast<typename Graph::Node>(n)); }
       
   997 //     bool valid(const Edge& e) const { 
       
   998 //       return graph->valid(static_cast<typename Graph::Edge>(e)); }
       
   999 
       
  1000 //     int nodeNum() const { return graph->nodeNum(); }
       
  1001 //     int edgeNum() const { return graph->edgeNum(); }
       
  1002   
       
  1003 //     Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
       
  1004 //     Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
       
  1005 //     Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
       
  1006 //     Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
       
  1007   
       
  1008 //     Node addNode() const { return Node(graph->addNode()); }
       
  1009 //     Edge addEdge(const Node& tail, const Node& head) const { 
       
  1010 //       return Edge(graph->addEdge(tail, head)); }
       
  1011 
       
  1012 //     void erase(const Node& i) const { graph->erase(i); }
       
  1013 //     void erase(const Edge& i) const { graph->erase(i); }
       
  1014   
       
  1015 //     void clear() const { graph->clear(); }
       
  1016     
       
  1017 //     template<typename T> class NodeMap : public Graph::NodeMap<T> { 
       
  1018 //     public:
       
  1019 //       NodeMap(const GraphWrapper<Graph>& _G) :  
       
  1020 // 	Graph::NodeMap<T>(*(_G.graph)) { }
       
  1021 //       NodeMap(const GraphWrapper<Graph>& _G, T a) : 
       
  1022 // 	Graph::NodeMap<T>(*(_G.graph), a) { }
       
  1023 //     };
       
  1024 
       
  1025 //     template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 
       
  1026 //     public:
       
  1027 //       EdgeMap(const GraphWrapper<Graph>& _G) :  
       
  1028 // 	Graph::EdgeMap<T>(*(_G.graph)) { }
       
  1029 //       EdgeMap(const GraphWrapper<Graph>& _G, T a) : 
       
  1030 // 	Graph::EdgeMap<T>(*(_G.graph), a) { }
       
  1031 //     };
       
  1032 //   };
       
  1033 
   855 } //namespace hugo
  1034 } //namespace hugo
   856 
  1035 
   857 #endif //HUGO_GRAPH_WRAPPER_H
  1036 #endif //HUGO_GRAPH_WRAPPER_H
   858 
  1037