diff --git a/alib2algo/src/graph/spanningtree/Edmonds.cpp b/alib2algo/src/graph/spanningtree/Edmonds.cpp index 7f4ae28f6d9d8e06a68b9e93280c6c43fc478fb3..64e59edacb49b10b089076c89877921631b080e6 100644 --- a/alib2algo/src/graph/spanningtree/Edmonds.cpp +++ b/alib2algo/src/graph/spanningtree/Edmonds.cpp @@ -25,8 +25,6 @@ namespace graph { namespace spanningtree { -using namespace std; - //==================================================================================================== // data structures @@ -38,7 +36,7 @@ struct Edge { int weight; int origWeight; Edge * fParent; - vector<Edge*> fChildren; + std::vector<Edge*> fChildren; bool deleted; Edge( const DirectedEdge & edge, uint from, uint to, int weight ) @@ -75,7 +73,7 @@ class EdgeQueue : public BinomialHeap<Edge*> { }; template< typename Type > -void vector_remove( vector<Type> & vec, Type elem ) +void vector_remove( std::vector<Type> & vec, Type elem ) { for (auto it = vec.begin(); it != vec.end(); it++) { if (*it == elem) { @@ -95,17 +93,17 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) uint nodeCnt = graph.nodeCount(); uint edgeCnt = graph.edgeCount(); - list<Edge> edges; // just to ease deallocation - queue<uint> roots; ///< silne komponenty, ktere jsou koreny v aktualnim grafu (nevede do nich zadny uzel) + std::list<Edge> edges; // just to ease deallocation + std::queue<uint> roots; ///< silne komponenty, ktere jsou koreny v aktualnim grafu (nevede do nich zadny uzel) Array<EdgeQueue> queues( nodeCnt ); ///< vstupni hrany do danych uzlu (razene dle priority) Array<Edge*> enter( nodeCnt ); ///< vstupni hrany do silnych komponent - Array<vector<Edge*>> h( nodeCnt ); ///< hrany, ktere mohou byt v kostre - vector<uint> rset; ///< rooti vyslednych stromu Tarjanovy implementace + Array<std::vector<Edge*>> h( nodeCnt ); ///< hrany, ktere mohou byt v kostre + std::vector<uint> rset; ///< rooti vyslednych stromu Tarjanovy implementace Components2 strong( nodeCnt ); ///< silne komponenty (reprezentanti) Components2 weak( nodeCnt ); ///< slabe komponenty (reprezentanti) Array<uint> min( nodeCnt ); ///< urcuje finalni korenove uzly orientovanych koster - vector<Edge*> fRoots; ///< koreny lesa F - Array<vector<Edge*>> cycles( nodeCnt ); ///< nalezene cykly + std::vector<Edge*> fRoots; ///< koreny lesa F + Array<std::vector<Edge*>> cycles( nodeCnt ); ///< nalezene cykly Array<Edge*> lambda( nodeCnt ); ///< listy lesa F // this algorithm works on number identification of nodes and edges @@ -175,7 +173,7 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) int maxVal = INT_MIN; int vertex = INT_MIN; - vector<Edge*> & cycle = cycles[ strong.Find( root ) ]; + std::vector<Edge*> & cycle = cycles[ strong.Find( root ) ]; cycle.clear(); while (cycleEdge != NULL) { //hledame hranu v cyklu s maximalni vahou (ktera nejvice poskodi cyklus) cycle.push_back( cycleEdge ); @@ -202,8 +200,8 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) } - vector<Edge*> b; - vector<uint> r; + std::vector<Edge*> b; + std::vector<uint> r; uint fRootIndex = 0; while (!rset.empty() || fRootIndex < fRoots.size()) { diff --git a/alib2data/src/graph/directed/DirectedGraph.h b/alib2data/src/graph/directed/DirectedGraph.h index f132634b279abec140e0d3bba84d0792d8afdf95..6785a0d16e826f7df67d9e510396f65f595d735f 100644 --- a/alib2data/src/graph/directed/DirectedGraph.h +++ b/alib2data/src/graph/directed/DirectedGraph.h @@ -36,7 +36,7 @@ class DirectedGraph : public GraphBase { DirectedGraph & operator=( DirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; - virtual REPRESENTATION getRepresentation() const = 0; + virtual REPRESENTATION getRepresentation() const override = 0 ; /// constructs an directed graph from any representation of other directed graph void fromDirected( const DirectedGraph & orig ); @@ -97,7 +97,7 @@ class DirectedGraph : public GraphBase { // commmon methods - int compare( const ObjectBase & other ) const { + int compare( const ObjectBase & other ) const override { if (std::type_index( typeid( *this ) ) == std::type_index( typeid( other ) )) return this->compare( (decltype( *this ))other ); return std::type_index( typeid( *this ) ) - std::type_index( typeid( other ) ); diff --git a/alib2data/src/graph/undirected/UndirectedGraph.h b/alib2data/src/graph/undirected/UndirectedGraph.h index e622b690c1d36108f223769b7150e1e11771cb9a..18e2197729d91bbc48ad0bf1249714b1a6712a06 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.h +++ b/alib2data/src/graph/undirected/UndirectedGraph.h @@ -36,7 +36,7 @@ class UndirectedGraph : public GraphBase { UndirectedGraph & operator=( UndirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; - virtual REPRESENTATION getRepresentation() const = 0; + virtual REPRESENTATION getRepresentation() const override = 0; /// constructs an undirected graph from any representation of other undirected graph void fromUndirected( const UndirectedGraph & orig ); @@ -89,7 +89,7 @@ class UndirectedGraph : public GraphBase { // common methods - int compare( const ObjectBase & other ) const { + int compare( const ObjectBase & other ) const override { if (std::type_index( typeid( *this ) ) == std::type_index( typeid( other ) )) return this->compare( (decltype( *this ))other ); return std::type_index( typeid( *this ) ) - std::type_index( typeid( other ) );