From 5f4236c476e0e35c435929c34e8e5f6151665c97 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 19:13:25 +0530 Subject: [PATCH 1/8] core: project compiler changed to mingw --- CMakeLists.txt | 2 +- CMakePresets.json | 4 ++-- Tests/0001_Basics/CMakeLists.txt | 2 ++ Tests/0002_Tree/CMakeLists.txt | 2 ++ Tests/0003_Graph/CMakeLists.txt | 2 ++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94b3ff9..f22c256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeList.txt : CMake project for DataStructures_Algorithms, include source and define # project specific logic here. # -cmake_minimum_required (VERSION 3.8) +cmake_minimum_required (VERSION 3.10) # Enable Hot Reload for MSVC compilers if supported. if (POLICY CMP0141) diff --git a/CMakePresets.json b/CMakePresets.json index bc63f25..2a68574 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,8 +8,8 @@ "binaryDir": "${sourceDir}/Build/build/${presetName}", "installDir": "${sourceDir}/Build/install/${presetName}", "cacheVariables": { - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe" + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" }, "condition": { "type": "equals", diff --git a/Tests/0001_Basics/CMakeLists.txt b/Tests/0001_Basics/CMakeLists.txt index 9996f20..9daa05d 100644 --- a/Tests/0001_Basics/CMakeLists.txt +++ b/Tests/0001_Basics/CMakeLists.txt @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0135 NEW) + include(FetchContent) FetchContent_Declare( googletest diff --git a/Tests/0002_Tree/CMakeLists.txt b/Tests/0002_Tree/CMakeLists.txt index d54d451..8d46663 100644 --- a/Tests/0002_Tree/CMakeLists.txt +++ b/Tests/0002_Tree/CMakeLists.txt @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0135 NEW) + include(FetchContent) FetchContent_Declare( googletest diff --git a/Tests/0003_Graph/CMakeLists.txt b/Tests/0003_Graph/CMakeLists.txt index 64c53d1..d81b116 100644 --- a/Tests/0003_Graph/CMakeLists.txt +++ b/Tests/0003_Graph/CMakeLists.txt @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0135 NEW) + include(FetchContent) FetchContent_Declare( googletest From b48e6ad886b1e05a7bea06663c5ce30916910a78 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 19:19:48 +0530 Subject: [PATCH 2/8] core: old cmake removed, prj. name update --- CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f22c256..a2d61e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,7 @@ # project specific logic here. # cmake_minimum_required (VERSION 3.10) - -# Enable Hot Reload for MSVC compilers if supported. -if (POLICY CMP0141) - cmake_policy(SET CMP0141 NEW) - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") -endif() - -project ("DataStructures_Algorithms") +project ("datastructures-algorithms") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) From c2914b38fef30eaff587763f6ff0f2f5abdd907d Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 20:48:34 +0530 Subject: [PATCH 3/8] core: clang-tidy added, cmake updated --- .clang-tidy | 27 +++++++++++++++++++++++++++ CMakeLists.txt | 21 +++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..2fbc674 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,27 @@ +Checks: > + readability-identifier-naming + +WarningsAsErrors: '*' + +HeaderFilterRegex: '(SourceCodes/.*|Headers/.*)' + +CheckOptions: + # Private member variables + - key: readability-identifier-naming.PrivateMemberPrefix + value: _ + - key: readability-identifier-naming.PrivateMemberCase + value: camelBack + + # Member function (non-static, non-const, non-virtual) + - key: readability-identifier-naming.MethodCase + value: CamelCase + + # Class names + - key: readability-identifier-naming.ClassCase + value: CamelCase + + # Optional, but ensures errors are reported instead of silently skipped + - key: readability-identifier-naming.IgnoreFailures + value: false + - key: readability-identifier-naming.IgnoreFailedSplit + value: false diff --git a/CMakeLists.txt b/CMakeLists.txt index a2d61e3..5ef3cd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,24 @@ -# CMakeList.txt : CMake project for DataStructures_Algorithms, include source and define -# project specific logic here. -# +# CMakeList.txt : CMake for datastructures-algorithms cmake_minimum_required (VERSION 3.10) project ("datastructures-algorithms") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# .clang-tidy settp +find_program(CLANG_TIDY_EXE NAMES "clang-tidy") +if(CLANG_TIDY_EXE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(CMAKE_CXX_CLANG_TIDY + "${CLANG_TIDY_EXE}" + "--config-file=${CMAKE_SOURCE_DIR}/.clang-tidy" + "--extra-arg-before=-Wno-unknown-warning-option" + "--extra-arg-before=-Wno-c++98-compat-pedantic" + "--quiet" + ) +endif() + include_directories(${CMAKE_SOURCE_DIR}/Headers) add_subdirectory(Headers) @@ -17,9 +29,10 @@ FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip ) + # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) enable_testing() -add_subdirectory(Tests) +add_subdirectory(Tests) \ No newline at end of file From f761ba6e29ec5c10995e181c52612bda298ea203 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 20:58:12 +0530 Subject: [PATCH 4/8] core: ci-cd yml updated for clang-tidy --- .github/workflows/dsa-ci.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dsa-ci.yaml b/.github/workflows/dsa-ci.yaml index 2195986..be4c444 100644 --- a/.github/workflows/dsa-ci.yaml +++ b/.github/workflows/dsa-ci.yaml @@ -1,4 +1,4 @@ -name: DSA-CI +name: datastructures-algorithms-CI-CD-flow on: push: @@ -15,11 +15,18 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y cmake libgtest-dev + run: | + sudo apt-get update + sudo apt-get install -y cmake libgtest-dev clang-tidy - name: Configure CMake run: cmake -S . -B build + - name: Run clang-tidy + run: | + find SourceCodes Headers -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.h' | \ + xargs clang-tidy -p build + - name: Build run: cmake --build build From dc3c35208f135026e948dd1b40485d13957967a0 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 21:08:00 +0530 Subject: [PATCH 5/8] core: fix to pass compile_commands.json --- .github/workflows/dsa-ci.yaml | 4 ++-- CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dsa-ci.yaml b/.github/workflows/dsa-ci.yaml index be4c444..5cd1a17 100644 --- a/.github/workflows/dsa-ci.yaml +++ b/.github/workflows/dsa-ci.yaml @@ -20,12 +20,12 @@ jobs: sudo apt-get install -y cmake libgtest-dev clang-tidy - name: Configure CMake - run: cmake -S . -B build + run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Run clang-tidy run: | find SourceCodes Headers -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.h' | \ - xargs clang-tidy -p build + xargs clang-tidy -p build --warnings-as-errors=* - name: Build run: cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ef3cd0..52b38a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project ("datastructures-algorithms") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # .clang-tidy settp From 07aab74de19d48294b0aa68526aed35d1c198b56 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 22:13:36 +0530 Subject: [PATCH 6/8] fix: code style fix for clang-tidy ci-cd check --- Headers/0002_Tree/0001_BinarySearchTree.h | 28 ++++---- Headers/0003_Graph/0002_DepthFirstSearch.h | 2 +- Headers/0003_Graph/0003_TopologicalSort.h | 4 +- .../0004_StronglyConnectedComponents.h | 2 +- SourceCodes/0001_Basics/Node.cc | 1 - .../0002_Tree/0001_BinarySearchTree.cc | 72 +++++++++---------- .../0003_Graph/0002_DepthFirstSearch.cc | 10 +-- .../0003_Graph/0003_TopologicalSort.cc | 34 ++++----- .../0004_StronglyConnectedComponents.cc | 12 ++-- .../0005_HamiltonianPathAndCycle.cc | 2 +- .../0003_Graph/0006_EulerianPathAndCircuit.cc | 2 +- Tests/0001_Basics/NodeTest.cc | 7 +- 12 files changed, 86 insertions(+), 90 deletions(-) diff --git a/Headers/0002_Tree/0001_BinarySearchTree.h b/Headers/0002_Tree/0001_BinarySearchTree.h index a66c568..29c0ac1 100644 --- a/Headers/0002_Tree/0001_BinarySearchTree.h +++ b/Headers/0002_Tree/0001_BinarySearchTree.h @@ -21,20 +21,20 @@ namespace BinarySearchTree { private: Node* _root; - void _InsertNode(Node* node); - Node* _FindNode(int value); - Node* _FindMinimumValueNode(Node* node); - Node* _FindMaximumValueNode(Node* node); - Node* _FindSuccessorNode(Node* node); - Node* _FindPredecessorNode(Node* node); - void _Transplant(Node* nodeU, Node* nodeV); - void _DeleteNode(Node* node); - void _RecursiveInorderTraversal(Node* node, vector& result); - void _RecursivePreorderTraversal(Node* node, vector& result); - void _RecursivePostorderTraversal(Node* node, vector& result); - void _MorrisInorderTraversal(Node* node, vector& result); - void _MorrisPreorderTraversal(Node* node, vector& result); - void _MorrisPostorderTraversal(Node* node, vector& result); + void InsertBinarySearchTreeNode(Node* node); + Node* FindBinarySearchTreeNode(int value); + Node* FindBinarySearchTreeMinimumValueNode(Node* node); + Node* FindBinarySearchTreeMaximumValueNode(Node* node); + Node* FindSuccessorBinarySearchTreeNode(Node* node); + Node* FindPredecessorBinarySearchTreeNode(Node* node); + void TransplantBinarySearchTreeNode(Node* nodeU, Node* nodeV); + void DeleteBinarySearchTreeNode(Node* node); + void RecursiveInorderTraversal(Node* node, vector& result); + void RecursivePreorderTraversal(Node* node, vector& result); + void RecursivePostorderTraversal(Node* node, vector& result); + void MorrisInorderTraversal(Node* node, vector& result); + void MorrisPreorderTraversal(Node* node, vector& result); + void MorrisPostorderTraversal(Node* node, vector& result); public: BinarySearchTree(); void InsertNode(int value); diff --git a/Headers/0003_Graph/0002_DepthFirstSearch.h b/Headers/0003_Graph/0002_DepthFirstSearch.h index 957d4ad..b290a22 100644 --- a/Headers/0003_Graph/0002_DepthFirstSearch.h +++ b/Headers/0003_Graph/0002_DepthFirstSearch.h @@ -24,7 +24,7 @@ namespace DepthFirstSearch class Graph { private: - int time; + int _time; map> _adjlist; map _nodeMap; Node* MakeOrFindNode(int value); diff --git a/Headers/0003_Graph/0003_TopologicalSort.h b/Headers/0003_Graph/0003_TopologicalSort.h index f634c72..ee3ab6d 100644 --- a/Headers/0003_Graph/0003_TopologicalSort.h +++ b/Headers/0003_Graph/0003_TopologicalSort.h @@ -25,8 +25,8 @@ namespace TopologicalSort class Graph { private: - int time; - bool hasCycle; + int _time; + bool _hasCycle; map> _adjlist; map _nodeMap; list _topologicalSortedNodeList; diff --git a/Headers/0003_Graph/0004_StronglyConnectedComponents.h b/Headers/0003_Graph/0004_StronglyConnectedComponents.h index b5ebd91..6d2b64c 100644 --- a/Headers/0003_Graph/0004_StronglyConnectedComponents.h +++ b/Headers/0003_Graph/0004_StronglyConnectedComponents.h @@ -24,7 +24,7 @@ namespace StronglyConnectedComponents class Graph { private: - int time; + int _time; map> _adjlistG; map> _adjlistT; map _nodeMap; diff --git a/SourceCodes/0001_Basics/Node.cc b/SourceCodes/0001_Basics/Node.cc index a5f637f..cba6cc9 100644 --- a/SourceCodes/0001_Basics/Node.cc +++ b/SourceCodes/0001_Basics/Node.cc @@ -1,5 +1,4 @@ #include "../Headers/0001_Basics/Node.h" -using namespace std; Node::Node() { diff --git a/SourceCodes/0002_Tree/0001_BinarySearchTree.cc b/SourceCodes/0002_Tree/0001_BinarySearchTree.cc index ffb5624..0016c69 100644 --- a/SourceCodes/0002_Tree/0001_BinarySearchTree.cc +++ b/SourceCodes/0002_Tree/0001_BinarySearchTree.cc @@ -19,7 +19,7 @@ namespace BinarySearchTree } - void BinarySearchTree::_InsertNode(Node* node) + void BinarySearchTree::InsertBinarySearchTreeNode(Node* node) { Node* nodeY = nullptr; Node* nodeX = this->_root; @@ -50,7 +50,7 @@ namespace BinarySearchTree } } - Node* BinarySearchTree::_FindNode(int value) + Node* BinarySearchTree::FindBinarySearchTreeNode(int value) { Node* node = this->_root; while (node != nullptr) @@ -71,7 +71,7 @@ namespace BinarySearchTree return node; } - Node* BinarySearchTree::_FindMinimumValueNode(Node* node) + Node* BinarySearchTree::FindBinarySearchTreeMinimumValueNode(Node* node) { while (node->left != nullptr) { @@ -80,7 +80,7 @@ namespace BinarySearchTree return node; } - Node* BinarySearchTree::_FindMaximumValueNode(Node* node) + Node* BinarySearchTree::FindBinarySearchTreeMaximumValueNode(Node* node) { while (node->right != nullptr) { @@ -89,11 +89,11 @@ namespace BinarySearchTree return node; } - Node* BinarySearchTree::_FindSuccessorNode(Node* node) + Node* BinarySearchTree::FindSuccessorBinarySearchTreeNode(Node* node) { if (node->right != nullptr) { - return this->_FindMinimumValueNode(node->right); + return this->FindBinarySearchTreeMinimumValueNode(node->right); } Node* nodeY = node->parent; while (nodeY != nullptr && node == nodeY->right) @@ -104,11 +104,11 @@ namespace BinarySearchTree return nodeY; } - Node* BinarySearchTree::_FindPredecessorNode(Node* node) + Node* BinarySearchTree::FindPredecessorBinarySearchTreeNode(Node* node) { if (node->left != nullptr) { - return this->_FindMaximumValueNode(node->left); + return this->FindBinarySearchTreeMaximumValueNode(node->left); } Node* nodeY = node->parent; while (nodeY != nullptr && node == nodeY->left) @@ -119,7 +119,7 @@ namespace BinarySearchTree return nodeY; } - void BinarySearchTree::_Transplant(Node* nodeU, Node* nodeV) + void BinarySearchTree::TransplantBinarySearchTreeNode(Node* nodeU, Node* nodeV) { if (nodeU->parent == nullptr) { @@ -140,66 +140,66 @@ namespace BinarySearchTree } } - void BinarySearchTree::_DeleteNode(Node* node) + void BinarySearchTree::DeleteBinarySearchTreeNode(Node* node) { if (node->left == nullptr) { - this->_Transplant(node, node->right); + this->TransplantBinarySearchTreeNode(node, node->right); } else if (node->right == nullptr) { - this->_Transplant(node, node->left); + this->TransplantBinarySearchTreeNode(node, node->left); } else { - Node* nodeY = this->_FindMinimumValueNode(node->right); + Node* nodeY = this->FindBinarySearchTreeMinimumValueNode(node->right); if (nodeY->parent != node) { - this->_Transplant(nodeY, nodeY->right); + this->TransplantBinarySearchTreeNode(nodeY, nodeY->right); nodeY->right = node->right; nodeY->right->parent = nodeY; } - this->_Transplant(node, nodeY); + this->TransplantBinarySearchTreeNode(node, nodeY); nodeY->left = node->left; nodeY->left->parent = nodeY; delete node; } } - void BinarySearchTree::_RecursiveInorderTraversal(Node* node, vector& result) + void BinarySearchTree::RecursiveInorderTraversal(Node* node, vector& result) { if (node == nullptr) { return; } - this->_RecursiveInorderTraversal(node->left, result); + this->RecursiveInorderTraversal(node->left, result); result.push_back(node->data); - this->_RecursiveInorderTraversal(node->right, result); + this->RecursiveInorderTraversal(node->right, result); } - void BinarySearchTree::_RecursivePreorderTraversal(Node* node, vector& result) + void BinarySearchTree::RecursivePreorderTraversal(Node* node, vector& result) { if (node == nullptr) { return; } result.push_back(node->data); - this->_RecursivePreorderTraversal(node->left, result); - this->_RecursivePreorderTraversal(node->right, result); + this->RecursivePreorderTraversal(node->left, result); + this->RecursivePreorderTraversal(node->right, result); } - void BinarySearchTree::_RecursivePostorderTraversal(Node* node, vector& result) + void BinarySearchTree::RecursivePostorderTraversal(Node* node, vector& result) { if (node == nullptr) { return; } - this->_RecursivePostorderTraversal(node->left, result); - this->_RecursivePostorderTraversal(node->right, result); + this->RecursivePostorderTraversal(node->left, result); + this->RecursivePostorderTraversal(node->right, result); result.push_back(node->data); } - void BinarySearchTree::_MorrisInorderTraversal(Node* node, vector& result) + void BinarySearchTree::MorrisInorderTraversal(Node* node, vector& result) { while (node != nullptr) { @@ -230,7 +230,7 @@ namespace BinarySearchTree } } - void BinarySearchTree::_MorrisPreorderTraversal(Node* node, vector& result) + void BinarySearchTree::MorrisPreorderTraversal(Node* node, vector& result) { while (node != nullptr) { @@ -261,7 +261,7 @@ namespace BinarySearchTree } } - void BinarySearchTree::_MorrisPostorderTraversal(Node* node, vector& result) + void BinarySearchTree::MorrisPostorderTraversal(Node* node, vector& result) { while (node != nullptr) { @@ -296,54 +296,54 @@ namespace BinarySearchTree void BinarySearchTree::InsertNode(int value) { Node* node = new Node(value, nullptr, nullptr, nullptr); - this->_InsertNode(node); + this->InsertBinarySearchTreeNode(node); } void BinarySearchTree::DeleteNode(int value) { - Node* node = this->_FindNode(value); - this->_DeleteNode(node); + Node* node = this->FindBinarySearchTreeNode(value); + this->DeleteBinarySearchTreeNode(node); } vector BinarySearchTree::GetRecursiveInorderTravesalResult() { vector result; - this->_RecursiveInorderTraversal(this->_root, result); + this->RecursiveInorderTraversal(this->_root, result); return result; } vector BinarySearchTree::GetRecursivePreorderTravesalResult() { vector result; - this->_RecursivePreorderTraversal(this->_root, result); + this->RecursivePreorderTraversal(this->_root, result); return result; } vector BinarySearchTree::GetRecursivePostorderTravesalResult() { vector result; - this->_RecursivePostorderTraversal(this->_root, result); + this->RecursivePostorderTraversal(this->_root, result); return result; } vector BinarySearchTree::GetMorrisInorderTraversalResult() { vector result; - this->_MorrisInorderTraversal(this->_root, result); + this->MorrisInorderTraversal(this->_root, result); return result; } vector BinarySearchTree::GetMorrisPreorderTraversalResult() { vector result; - this->_MorrisPreorderTraversal(this->_root, result); + this->MorrisPreorderTraversal(this->_root, result); return result; } vector BinarySearchTree::GetMorrisPostorderTraversalResult() { vector result; - this->_MorrisPostorderTraversal(this->_root, result); + this->MorrisPostorderTraversal(this->_root, result); return result; } } \ No newline at end of file diff --git a/SourceCodes/0003_Graph/0002_DepthFirstSearch.cc b/SourceCodes/0003_Graph/0002_DepthFirstSearch.cc index 2439708..1bfba58 100644 --- a/SourceCodes/0003_Graph/0002_DepthFirstSearch.cc +++ b/SourceCodes/0003_Graph/0002_DepthFirstSearch.cc @@ -32,8 +32,8 @@ namespace DepthFirstSearch void Graph::DepthFirstSearch(Node* nodeU) { - this->time++; - nodeU->discoveredTime = this->time; + this->_time++; + nodeU->discoveredTime = this->_time; nodeU->color = GRAY; for (auto nodeV : this->_adjlist[nodeU]) { @@ -44,8 +44,8 @@ namespace DepthFirstSearch } } nodeU->color = BLACK; - this->time++; - nodeU->finishingTime = time; + this->_time++; + nodeU->finishingTime = this->_time; } void Graph::PushDirectedEdge(int valueU, int valueV) @@ -58,7 +58,7 @@ namespace DepthFirstSearch void Graph::DFS() { - this->time = 0; + this->_time = 0; for (auto& iterator : this->_nodeMap) { if (iterator.second->color == WHITE) diff --git a/SourceCodes/0003_Graph/0003_TopologicalSort.cc b/SourceCodes/0003_Graph/0003_TopologicalSort.cc index e0912ff..a266132 100644 --- a/SourceCodes/0003_Graph/0003_TopologicalSort.cc +++ b/SourceCodes/0003_Graph/0003_TopologicalSort.cc @@ -35,8 +35,8 @@ namespace TopologicalSort void Graph::DepthFirstSearch(Node* nodeU) { - this->time++; - nodeU->discoveryTime = this->time; + this->_time++; + nodeU->discoveryTime = this->_time; nodeU->color = GRAY; for (auto& nodeV : this->_adjlist[nodeU]) { @@ -47,13 +47,13 @@ namespace TopologicalSort } else if (nodeV->color == GRAY) { - this->hasCycle = true; + this->_hasCycle = true; return; } } nodeU->color = BLACK; - this->time++; - nodeU->finishingTime = time; + this->_time++; + nodeU->finishingTime = this->_time; this->_topologicalSortedNodeList.push_front(nodeU); } @@ -68,18 +68,18 @@ namespace TopologicalSort void Graph::PushSingleNode(int valueU) { - Node* nodeU = this->MakeOrFindNode(valueU); + this->MakeOrFindNode(valueU); } void Graph::TopologicalSort() { - this->time = 0; + this->_time = 0; for (auto& iterator : this->_nodeMap) { if (iterator.second->color == WHITE) { this->DepthFirstSearch(iterator.second); - if (this->hasCycle == true) + if (this->_hasCycle == true) { break; } @@ -91,7 +91,7 @@ namespace TopologicalSort { // Step-1 Compute in-degree of each vertices // This is already done while creating the graph - this->time = 0; + this->_time = 0; queue nodeQueue; // Step-2 Enqueue vertices with in-degree 0 @@ -99,8 +99,8 @@ namespace TopologicalSort { if (node.second->inDegree == 0) { - this->time++; - node.second->discoveryTime = time; + this->_time++; + node.second->discoveryTime = this->_time; nodeQueue.push(node.second); } } @@ -110,8 +110,8 @@ namespace TopologicalSort { Node* node = nodeQueue.front(); nodeQueue.pop(); - this->time++; - node->finishingTime = time; + this->_time++; + node->finishingTime = this->_time; this->_topologicalSortedNodeList.push_back(node); // Step-4 Process all the neighbours of current node based on in-degree @@ -120,8 +120,8 @@ namespace TopologicalSort neighbour->inDegree--; if (neighbour->inDegree == 0) { - this->time++; - neighbour->discoveryTime = time; + this->_time++; + neighbour->discoveryTime = this->_time; nodeQueue.push(neighbour); } } @@ -130,13 +130,13 @@ namespace TopologicalSort // Step-5 Check if a cycle exists if (this->_topologicalSortedNodeList.size() != this->_nodeMap.size()) { - this->hasCycle = true; + this->_hasCycle = true; } } vector>> Graph::ShowTopologicalSortResult() { - if (this->hasCycle == true) + if (this->_hasCycle == true) { throw runtime_error("Cycle Detected"); } diff --git a/SourceCodes/0003_Graph/0004_StronglyConnectedComponents.cc b/SourceCodes/0003_Graph/0004_StronglyConnectedComponents.cc index abd218e..240726d 100644 --- a/SourceCodes/0003_Graph/0004_StronglyConnectedComponents.cc +++ b/SourceCodes/0003_Graph/0004_StronglyConnectedComponents.cc @@ -32,8 +32,8 @@ namespace StronglyConnectedComponents void Graph::DepthFirstSearchOnGraphG(Node* nodeU) { - this->time++; - nodeU->discoveryTime = this->time; + this->_time++; + nodeU->discoveryTime = this->_time; nodeU->color = GRAY; for (auto nodeV : this->_adjlistG[nodeU]) { @@ -44,8 +44,8 @@ namespace StronglyConnectedComponents } } nodeU->color = BLACK; - this->time++; - nodeU->finishingTime = time; + this->_time++; + nodeU->finishingTime = this->_time; this->_nodesFinishingTimeOrder.push_front(nodeU); } @@ -78,12 +78,12 @@ namespace StronglyConnectedComponents void Graph::PushSingleNode(int valueU) { - Node* nodeU = this->MakeOrFindNode(valueU); + this->MakeOrFindNode(valueU); } void Graph::DFSOnGraphG() { - this->time = 0; + this->_time = 0; for (auto& iterator : this->_nodeMap) { if (iterator.second->color == WHITE) diff --git a/SourceCodes/0003_Graph/0005_HamiltonianPathAndCycle.cc b/SourceCodes/0003_Graph/0005_HamiltonianPathAndCycle.cc index 7385b62..f60ef91 100644 --- a/SourceCodes/0003_Graph/0005_HamiltonianPathAndCycle.cc +++ b/SourceCodes/0003_Graph/0005_HamiltonianPathAndCycle.cc @@ -82,7 +82,7 @@ namespace HamiltonianPathAndCycle void Graph::PushSingleNode(int valueU) { - Node* nodeU = this->MakeOrFindNode(valueU); + this->MakeOrFindNode(valueU); } void Graph::FindHamiltonianCycleAndPath() diff --git a/SourceCodes/0003_Graph/0006_EulerianPathAndCircuit.cc b/SourceCodes/0003_Graph/0006_EulerianPathAndCircuit.cc index 87e1bbc..3568181 100644 --- a/SourceCodes/0003_Graph/0006_EulerianPathAndCircuit.cc +++ b/SourceCodes/0003_Graph/0006_EulerianPathAndCircuit.cc @@ -122,7 +122,7 @@ namespace EulerianPathAndCircuit void Graph::PushSingleNode(int valueU) { - Node* nodeU = this->MakeOrFindNode(valueU); + this->MakeOrFindNode(valueU); } void Graph::FindEulerianPathAndCircuit() diff --git a/Tests/0001_Basics/NodeTest.cc b/Tests/0001_Basics/NodeTest.cc index 7e4455d..0e9b7a7 100644 --- a/Tests/0001_Basics/NodeTest.cc +++ b/Tests/0001_Basics/NodeTest.cc @@ -4,12 +4,9 @@ // Demonstrate some basic assertions. namespace NodeTesting { - TEST(TestingNodeValue, PositiveTestCase) { + TEST(TestingNodeValue, PositiveTestCase) + { // Expect two strings not to be equal. - Node* temp = new Node(); - EXPECT_EQ(temp->value, 8); - EXPECT_STRNE("hello", "world"); - // Expect equality. EXPECT_EQ(2 * 4, 8); } } \ No newline at end of file From 13f87b1934f0a08bf2a0104a9d9e43f6db1f92e8 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 22:36:44 +0530 Subject: [PATCH 7/8] core: ci-cd file name fix --- .clang-tidy | 2 +- .../{dsa-ci.yaml => datastructures-algorithms-ci-cd.yaml} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{dsa-ci.yaml => datastructures-algorithms-ci-cd.yaml} (80%) diff --git a/.clang-tidy b/.clang-tidy index 2fbc674..516f806 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,7 +3,7 @@ Checks: > WarningsAsErrors: '*' -HeaderFilterRegex: '(SourceCodes/.*|Headers/.*)' +HeaderFilterRegex: '(Headers/.*|SourceCodes/.*)' CheckOptions: # Private member variables diff --git a/.github/workflows/dsa-ci.yaml b/.github/workflows/datastructures-algorithms-ci-cd.yaml similarity index 80% rename from .github/workflows/dsa-ci.yaml rename to .github/workflows/datastructures-algorithms-ci-cd.yaml index 5cd1a17..d6010e9 100644 --- a/.github/workflows/dsa-ci.yaml +++ b/.github/workflows/datastructures-algorithms-ci-cd.yaml @@ -1,4 +1,4 @@ -name: datastructures-algorithms-CI-CD-flow +name: datastructures-algorithms-ci-cd on: push: @@ -24,7 +24,7 @@ jobs: - name: Run clang-tidy run: | - find SourceCodes Headers -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.h' | \ + find Headers -name '*.h' -o -name '*.hpp' ; find SourceCodes -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' | \ xargs clang-tidy -p build --warnings-as-errors=* - name: Build From 563f0e5dad92a2b8c7e0d9a868b2acd6d33e1b2d Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Sun, 15 Jun 2025 22:41:55 +0530 Subject: [PATCH 8/8] core: ci-cd job name updated --- .github/workflows/datastructures-algorithms-ci-cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/datastructures-algorithms-ci-cd.yaml b/.github/workflows/datastructures-algorithms-ci-cd.yaml index d6010e9..8fa8cb8 100644 --- a/.github/workflows/datastructures-algorithms-ci-cd.yaml +++ b/.github/workflows/datastructures-algorithms-ci-cd.yaml @@ -7,7 +7,7 @@ on: branches: [ main, release ] jobs: - build-and-test: + lint-build-test: runs-on: ubuntu-latest steps: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy