marci@151: marci@151: marci@154: BfsIterator4typename Graph, typename OutEdgeIt, marci@154: typename ReachedMap]]> marci@151: marci@151: marci@151: marci@154: The class IteratorBfs4 typename Graph, typename OutEdgeIt, marci@154: typename ReachedMap]]> implements an edge iterator which iterates on the edges of a directed or undirected graph in a breadth first search order. As a bare iterator, it stores the actual edge, the bfs queue and the map of reached nodes. The usual interpretation of bfs consists of computing auxiliary quantities i.e. distance from root or tree of edges on which the reachable nodes were reached. This iterator approach entrusts such functionalities to the user, they have to be implemented out of the class. marci@151: Ez itt egy tobbsoros, tobb reszes leiras arrol, hogy altalanossagban marci@151: mire is jo ez az osztaly. Ez itt egy tobbsoros, tobb reszes leiras marci@151: arrol, hogy altalanossagban mire is jo ez az osztaly. marci@151: marci@151: Ez itt az uj bekezdese a leirasnak, mert elofordulhat, hogy tobb marci@151: bekezdesre erdemes tagolni az iromanyt. marci@151: marci@151: marci@151: marci@151: marci@151: Gyakran hasznos egy peldan bemutatni a mukodest. A kovetkezo egy marci@151: egyszeru kis szemleltetes arra, hogy ezt milyen konnyen es gyorsan marci@151: lehet hasznalni: marci@151: marci@151: marci@151: struct eqstr marci@151: { marci@151: bool operator()(const char* s1, const char* s2) const marci@151: { marci@151: return strcmp(s1, s2) == 0; marci@151: } marci@151: }; marci@151: marci@151: void lookup(const map_type& Map, const char* str) marci@151: { marci@151: marci@151: } marci@151: marci@151: marci@151: marci@151: Vigyázat, a programlisting mód parsolt, és minden -t értelmez! marci@151: marci@151: beckerjc@153: my_edge_property(G); marci@151: for(EachEdgeIt i=G.first(); i.valid(); ++i) { marci@151: my_edge_property.set(i, _i); marci@151: _i*=_ii; ++_ii; marci@151: } beckerjc@153: ]]> marci@151: marci@151: marci@151: marci@151: marci@154: Defined in bfs_iterator.hh. marci@151: Ez a definition szekcio arra van, hogy beleirjuk, hogy milyen fajlban marci@151: van definialva az aktualis osztaly. marci@151: Ez egy link a tutorialra. marci@151: marci@151: marci@151: marci@151: marci@151: marci@154: Graph marci@151: marci@151: marci@154: Graph is a graph type which have to satisfy some concept requirements defined at a later date. marci@151: marci@151: marci@154: Mittomen marci@151: Legyen implementalva neki az osszehasonlito operator. marci@151: marci@151: marci@151: Az nincs marci@151: marci@151: marci@151: marci@151: marci@154: OutEdgeIt marci@151: marci@151: marci@154: OutEdgeIt is an edge iterator type. marci@154: The bfs iterator iterates on the edges. marci@151: Az Af template parameter is egy olyan vacak, ami a generikussaghoz kell. marci@151: marci@151: marci@151: Af szarmazzon az elemi osztalyokbol. marci@151: marci@151: marci@151: 0 marci@151: marci@151: marci@154: marci@154: marci@154: ReachedMap marci@154: marci@154: marci@154: ReachedMap is a map type which stores a bool for each node, and will ne used to maintain the set of reached nodes. marci@154: Az Af template parameter is egy olyan vacak, ami a generikussaghoz kell. marci@154: marci@154: marci@154: Readable and Writable nodemap. marci@154: Af szarmazzon az elemi osztalyokbol. marci@154: marci@154: marci@154: 0 marci@154: marci@154: marci@151: marci@151: marci@151: marci@151: marci@154: marci@151: marci@151: marci@154: BfsIterator4(const Graph& _G, ReachedMap& _reached) marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: Creates a bfs iterator with empty queue. The reached nodes will be stores in marci@154: the map for that _reached refers. Initially, _reached have to be an everywhere marci@154: false map. Other cases also can be specified, but due to the difficulty, I have no stomach to deal with it. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: BfsIterator4(const Graph& _G) marci@154: marci@154: marci@154: - marci@154: marci@154: marci@154: The same as above, but an own map is constructed to store the reached nodes (and is destroyed at the and). marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: void pushAndSetReached(NodeIt s) marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: Inserts s in the bfs queue and marks it reached. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: BfsIterator4Graph, OutEdgeIt, ReachedMap]]>& operator++() marci@151: marci@151: marci@151: container marci@151: marci@151: marci@154: Executes one step on the bfs iterator. marci@151: marci@151: marci@151: marci@154: marci@151: marci@151: marci@154: bool finished() const marci@151: marci@151: marci@154: container marci@151: marci@151: marci@154: Returns true if and only if the iteration is finished. marci@151: marci@151: marci@151: marci@154: marci@154: marci@154: marci@154: operator OutEdgeIt () const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: This conversion operator returns the actual value of the bfs iterator. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: bool isBNodeNewlyReached() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Precondition: OutEdgeIt() returns a valid iterator. marci@154: Returns true if and only if bNode of OutEdgeIt() is reached at the last marci@154: iteration step. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: bool isANodeExamined() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Returns true if and only if the actual node bacomes examined. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: NodeIt aNode() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Returns the actual node. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: NodeIt bNode() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Precondition: OutEdgeIt() returns a valid iterator. marci@154: Returns bNode of the actual edge.. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: const ReachedMap& getReachedMap() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Const reference to the reached map. marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: marci@154: const std::queueNodeIt]]>& getBfsQueue() const marci@154: marci@154: marci@154: container marci@154: marci@154: marci@154: Const reference to the bfs queue. marci@154: marci@154: marci@154: marci@154: marci@154: marci@151: marci@151: marci@151: marci@151: marci@151: marci@151: marci@151: marci@151: marci@151: