src/work/marci/graph_wrapper.h
changeset 381 d72470496fbe
parent 380 6399494e30b1
child 389 770cc1f4861f
equal deleted inserted replaced
45:bcda0d911d86 46:3c58571359b2
   905       ClassNodeIt() { }
   905       ClassNodeIt() { }
   906       ClassNodeIt(const Invalid& i) : n(i) { }
   906       ClassNodeIt(const Invalid& i) : n(i) { }
   907       ClassNodeIt(const BipartiteGraphWrapper<Graph>& _G, bool _class) { 
   907       ClassNodeIt(const BipartiteGraphWrapper<Graph>& _G, bool _class) { 
   908 	_G.s_false_t_true_map->first(n, _class); 
   908 	_G.s_false_t_true_map->first(n, _class); 
   909       }
   909       }
       
   910       //FIXME needed in new concept, important here
       
   911       ClassNodeIt(const Node& _n) : n(_n) { }
   910       operator Node() const { return n; }
   912       operator Node() const { return n; }
   911     };
   913     };
   912 //     class SNodeIt {
   914 //     class SNodeIt {
   913 //       Node n;
   915 //       Node n;
   914 //     public:
   916 //     public:
  1009     Node bNode(const InEdgeIt& e) const { 
  1011     Node bNode(const InEdgeIt& e) const { 
  1010       return Node(this->graph->bNode(e.e)); 
  1012       return Node(this->graph->bNode(e.e)); 
  1011     }
  1013     }
  1012 
  1014 
  1013     bool inSClass(const Node& n) const {
  1015     bool inSClass(const Node& n) const {
  1014       return !(this->s_false_t_true_map[n]);
  1016       return !(*(this->s_false_t_true_map))[n];
  1015     }
  1017     }
  1016     bool inTClass(const Node& n) const {
  1018     bool inTClass(const Node& n) const {
  1017       return (this->s_false_t_true_map[n]);
  1019       return (*(this->s_false_t_true_map))[n];
  1018     }
  1020     }
  1019   };
  1021   };
  1020 
  1022 
  1021 
  1023 
  1022   /// experimentral, do not try it.
  1024   /// experimentral, do not try it.
  1024   /// Such one can be made e.g. by the above wrapper.
  1026   /// Such one can be made e.g. by the above wrapper.
  1025   template<typename Graph>
  1027   template<typename Graph>
  1026   class stGraphWrapper : public GraphWrapper<Graph> {
  1028   class stGraphWrapper : public GraphWrapper<Graph> {
  1027   public:
  1029   public:
  1028     class Node; 
  1030     class Node; 
       
  1031     friend class Node;
  1029 //GN, int
  1032 //GN, int
  1030 //0 normalis, 1 s, 2, true, ez az iteralasi sorrend, 
  1033 //0 normalis, 1 s, 2, true, ez az iteralasi sorrend, 
  1031 //es a vege a false azaz (invalid, 3)    
  1034 //es a vege a false azaz (invalid, 3)    
  1032     class NodeIt;
  1035     class NodeIt;
       
  1036     friend class NodeIt;
  1033 //GNI, int
  1037 //GNI, int
  1034     class Edge;
  1038     class Edge;
       
  1039     friend class Edge;
  1035 //GE, int, GN
  1040 //GE, int, GN
  1036 //0 normalis, 1 s->vmi, 2 vmi->t, ez a sorrend,
  1041 //0 normalis, 1 s->vmi, 2 vmi->t, ez a sorrend,
  1037 //invalid: (invalid, 3, invalid)
  1042 //invalid: (invalid, 3, invalid)
  1038     class OutEdgeIt;
  1043     class OutEdgeIt;
       
  1044     friend class OutEdgeIt;
  1039 //GO, int, GNI
  1045 //GO, int, GNI
  1040 //normalis pontbol (first, 0, invalid), ..., (invalid, 2, vmi), ... (invalid, 3, invalid)
  1046 //normalis pontbol (first, 0, invalid), ..., (invalid, 2, vmi), ... (invalid, 3, invalid)
  1041 //s-bol (invalid, 1, first), ... (invalid, 3, invalid)
  1047 //s-bol (invalid, 1, first), ... (invalid, 3, invalid)
  1042 //t-bol (invalid, 3, invalid)
  1048 //t-bol (invalid, 3, invalid)
  1043     class InEdgeIt;
  1049     class InEdgeIt;
       
  1050     friend class InEdgeIt;
  1044 //GI, int, GNI
  1051 //GI, int, GNI
  1045 //normalis pontbol (first, 0, invalid), ..., (invalid, 1, vmi), ... (invalid, 3, invalid)
  1052 //normalis pontbol (first, 0, invalid), ..., (invalid, 1, vmi), ... (invalid, 3, invalid)
  1046 //s-be (invalid, 3, invalid)
  1053 //s-be (invalid, 3, invalid)
  1047 //t-be (invalid, 2, first), ... (invalid, 3, invalid)
  1054 //t-be (invalid, 2, first), ... (invalid, 3, invalid)
  1048     class EdgeIt;
  1055     class EdgeIt;
       
  1056     friend class EdgeIt;
  1049 //(first, 0, invalid) ...
  1057 //(first, 0, invalid) ...
  1050 //(invalid, 1, vmi)
  1058 //(invalid, 1, vmi)
  1051 //(invalid, 2, vmi)
  1059 //(invalid, 2, vmi)
  1052 //invalid, 3, invalid)
  1060 //invalid, 3, invalid)
  1053     template <typename T> class NodeMap;
  1061     template <typename T> class NodeMap;
  1101      public:
  1109      public:
  1102       NodeIt() { }
  1110       NodeIt() { }
  1103       NodeIt(const typename Graph::NodeIt& _n, int _spec) : 
  1111       NodeIt(const typename Graph::NodeIt& _n, int _spec) : 
  1104 	n(_n), spec(_spec) { }
  1112 	n(_n), spec(_spec) { }
  1105       NodeIt(const Invalid& i) : n(i), spec(3) { }
  1113       NodeIt(const Invalid& i) : n(i), spec(3) { }
  1106       NodeIt(const GraphWrapper<Graph>& _G) : n(*(_G.graph)), spec(0) { 
  1114       NodeIt(const stGraphWrapper<Graph>& _G) : n(*(_G.graph)), spec(0) { 
  1107 	if (!_G->valid(n)) spec=1;
  1115 	if (!_G->valid(n)) spec=1;
  1108       }
  1116       }
  1109       operator Node() const { return Node(n, spec); }
  1117       operator Node() const { return Node(n, spec); }
  1110     };
  1118     };
  1111     class Edge : public Graph::Edge {
  1119     class Edge : public Graph::Edge {
  1146       OutEdgeIt(const typename Graph::OutEdgeIt& _e, int _spec, 
  1154       OutEdgeIt(const typename Graph::OutEdgeIt& _e, int _spec, 
  1147 		const typename Graph::ClassNodeIt& _n) : 
  1155 		const typename Graph::ClassNodeIt& _n) : 
  1148 	e(_e), spec(_spec), n(_n) { 
  1156 	e(_e), spec(_spec), n(_n) { 
  1149       }
  1157       }
  1150       OutEdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1158       OutEdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1151       OutEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) {
  1159       OutEdgeIt(const stGraphWrapper<Graph>& _G, const Node& _n) {
  1152 	switch (_n.spec) {
  1160 	switch (_n.spec) {
  1153 	  case 0 : 
  1161 	  case 0 : 
  1154 	    if (_G.graph->inSClass) { //S, van normalis kiel 
  1162 	    if (_G.graph->inSClass(_n)) { //S, van normalis kiel 
  1155 	      e=typename Graph::OutEdgeIt(*(_G.graph), 
  1163 	      e=typename Graph::OutEdgeIt(*(_G.graph), 
  1156 					  typename Graph::Node(_n)); 
  1164 					  typename Graph::Node(_n)); 
  1157 	      spec=0;
  1165 	      spec=0;
  1158 	      n=INVALID;
  1166 	      n=INVALID;
  1159 	      if (!_G.graph->valid(e)) spec=3;
  1167 	      if (!_G.graph->valid(e)) spec=3;
  1189       InEdgeIt(const typename Graph::InEdgeIt& _e, int _spec, 
  1197       InEdgeIt(const typename Graph::InEdgeIt& _e, int _spec, 
  1190 	       const typename Graph::ClassNodeIt& _n) : 
  1198 	       const typename Graph::ClassNodeIt& _n) : 
  1191 	e(_e), spec(_spec), n(_n) { 
  1199 	e(_e), spec(_spec), n(_n) { 
  1192       }
  1200       }
  1193       InEdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1201       InEdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1194       InEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) {
  1202       InEdgeIt(const stGraphWrapper<Graph>& _G, const Node& _n) {
  1195 	switch (_n.spec) {
  1203 	switch (_n.spec) {
  1196 	  case 0 : 
  1204 	  case 0 : 
  1197 	    if (_G.graph->inTClass) { //T, van normalis beel 
  1205 	    if (_G.graph->inTClass(_n)) { //T, van normalis beel 
  1198 	      e=typename Graph::InEdgeIt(*(_G.graph), 
  1206 	      e=typename Graph::InEdgeIt(*(_G.graph), 
  1199 					 typename Graph::Node(_n)); 
  1207 					 typename Graph::Node(_n)); 
  1200 	      spec=0;
  1208 	      spec=0;
  1201 	      n=INVALID;
  1209 	      n=INVALID;
  1202 	      if (!_G.graph->valid(e)) spec=3;
  1210 	      if (!_G.graph->valid(e)) spec=3;
  1230       EdgeIt() { }
  1238       EdgeIt() { }
  1231       EdgeIt(const typename Graph::EdgeIt& _e, int _spec, 
  1239       EdgeIt(const typename Graph::EdgeIt& _e, int _spec, 
  1232 	     const typename Graph::ClassNodeIt& _n) : 
  1240 	     const typename Graph::ClassNodeIt& _n) : 
  1233 	e(_e), spec(_spec), n(_n) { }
  1241 	e(_e), spec(_spec), n(_n) { }
  1234       EdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1242       EdgeIt(const Invalid& i) : e(i), spec(3), n(i) { }
  1235       EdgeIt(const GraphWrapper<Graph>& _G) : 
  1243       EdgeIt(const stGraphWrapper<Graph>& _G) : 
  1236 	e(*(_G.graph)), spec(0), n(INVALID) { 
  1244 	e(*(_G.graph)), spec(0), n(INVALID) { 
  1237 	if (!_G.graph->valid(e)) {
  1245 	if (!_G.graph->valid(e)) {
  1238 	  spec=1;
  1246 	  spec=1;
  1239 	  _G.graph->first(n, S_CLASS);
  1247 	  _G.graph->first(n, S_CLASS);
  1240 	  if (!_G.graph->valid(n)) { //Ha S ures
  1248 	  if (!_G.graph->valid(n)) { //Ha S ures