Concept modification to resolve the item by its ID.
12 // struct NodeType {bfs_node_data<TestGraph> bfs;};
13 struct NodeType {bool isVis;};
15 vector<NodeType> nodes;
22 NodeIterator &operator ++() { n++; return *this;}
23 NodeType &operator *() const { return G->nodes[n];}
24 NodeType *operator ->() const { return &(G->nodes[n]);}
25 bool isValid() const {return n<=5000;}
26 int Index() {return n;} //csak a kiirashoz kell
29 NodeIterator(IGraph &Gr) {G=&Gr;n=1;} //Bfs class prefer this.
32 void GetFirst(NodeIterator &i) {i.G=this;i.n=1;}
39 int gcd() { int a=f;int b=t;int c;while((c=a%b)) {a=b;b=c;} ; return b;}
40 OutEdgeIterator &operator ++() {while(++t<=5000&&gcd()==1);return *this;}
41 bool isValid() const {return t<=5000;}
42 NodeIterator From() const {NodeIterator i; i.G=G;i.n=f;return i;}
43 NodeIterator To() const {NodeIterator i; i.G=G;i.n=t;return i;}
44 NodeIterator Anode() const {return From();}
45 NodeIterator Bnode() const {return To();}
48 OutEdgeIterator(IGraph &Gr,NodeIterator &n) //Bfs class prefer this.
49 {G=&Gr;f=n.n;t=0;operator++();}
52 typedef OutEdgeIterator EdgeIterator;
53 void GetFirst(OutEdgeIterator &i,const NodeIterator &n)
54 {i.G=this;i.f=n.n;i.t=0;++i;}
56 IGraph() : nodes(5001) {}
62 // class_element_map<IGraph::NodeIterator,
65 // &IGraph::NodeType::isVis> visited;
66 struct _visited_map_t {
67 typedef bool value_type;
68 void Put(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; }
69 value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; }
70 void SetG(IGraph &G) {}
73 typedef IGraph::EdgeIterator value_type;
74 void Put(const IGraph::NodeIterator &n,const value_type &t)
75 { cout << t.From().Index() << "->" << t.To().Index() << '\n'; }
76 void SetG(IGraph &G) {}
78 do_nothing_map dist; //node->int (W)
79 do_nothing_map priority; //node->int (W)
82 // New style bfs traits
88 typedef IGraph::OutEdgeIterator SearchEdgeIterator;
90 struct visited_map_t {
91 typedef bool value_type;
92 void Put(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; }
93 value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; }
94 void SetG(IGraph &G) {}
97 typedef IGraph::EdgeIterator value_type;
98 void Put(const IGraph::NodeIterator &n,const value_type &t)
99 { cout << t.From().Index() << "->" << t.To().Index() << '\n'; }
100 void SetG(IGraph &G) {}
102 typedef do_nothing_map dist_map_t; //node->int (W)
103 typedef do_nothing_map priority_map_t; //node->int (W)
111 // //Function-syte calling
114 // IGraph::NodeIterator in;
117 // bfs_fn(IG,in,IMaps);
119 //Class-style calling:
121 IGraph::NodeIterator in;