#include #include #include using namespace NEGRO; using namespace std; class IGraph { public: // struct NodeType {bfs_node_data bfs;}; struct NodeType {bool isVis;}; vector nodes; class NodeIterator { public: IGraph *G; int n; NodeIterator &operator ++() { n++; return *this;} NodeType &operator *() const { return G->nodes[n];} NodeType *operator ->() const { return &(G->nodes[n]);} bool isValid() const {return n<=5000;} int Index() {return n;} //csak a kiirashoz kell }; void GetFirst(NodeIterator &i) {i.G=this;i.n=1;} class OutEdgeIterator { public: IGraph *G; int f,t; int gcd() { int a=f;int b=t;int c;while((c=a%b)) {a=b;b=c;} ; return b;} OutEdgeIterator &operator ++() {while(++t<=5000&&gcd()==1);return *this;} bool isValid() const {return t<=5000;} NodeIterator From() const {NodeIterator i; i.G=G;i.n=f;return i;} NodeIterator To() const {NodeIterator i; i.G=G;i.n=t;return i;} NodeIterator Anode() const {return From();} NodeIterator Bnode() const {return To();} }; typedef OutEdgeIterator EdgeIterator; void GetFirst(OutEdgeIterator &i,const NodeIterator &n) {i.G=this;i.f=n.n;i.t=0;++i;} IGraph() : nodes(5001) {} }; class IMaps_t { public: // class_element_map visited; struct _visited_map_t { typedef bool value_type; void Put(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; } value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; } } visited; struct _tree_map_t { typedef IGraph::EdgeIterator value_type; void Put(const IGraph::NodeIterator &n,const value_type &t) { cout << t.From().Index() << "->" << t.To().Index() << '\n'; } } tree; do_nothing_map dist; //node->int (W) do_nothing_map priority; //node->int (W) }; int main() { IGraph IG; IMaps_t IMaps; IGraph::NodeIterator in; IG.GetFirst(in); ++in; bfs(IG,in,IMaps); }