Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create clang-format workflow #390

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: clang-format Check

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'benchmark'
- 'examples'
- 'include/CXXGraph'
- 'test'
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '16'
check-path: ${{ matrix.path }}
2 changes: 1 addition & 1 deletion benchmark/BellmanFord_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ static void BellmanFord_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(BellmanFord_FromReadedCitHep);
BENCHMARK(BellmanFord_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Boruvka_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ static void Boruvka_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(Boruvka_FromReadedCitHep);
BENCHMARK(Boruvka_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Connectivity_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ static void StrongConnectivity_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(StrongConnectivity_FromReadedCitHep);
BENCHMARK(StrongConnectivity_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/CycleCheck_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ static void CycleCheckDFS_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(CycleCheckDFS_FromReadedCitHep);
BENCHMARK(CycleCheckDFS_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Dial_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ static void Dial_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(Dial_FromReadedCitHep);
BENCHMARK(Dial_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Edge_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ static void NodeGetNodePair(benchmark::State &state) {
e.getNodePair();
}
}
BENCHMARK(NodeGetNodePair);
BENCHMARK(NodeGetNodePair);
1 change: 1 addition & 0 deletions benchmark/FloydWarshall_BM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <benchmark/benchmark.h>

#include <memory>

#include "CXXGraph/CXXGraph.hpp"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/FordFulkerson_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ static void FordFulkerson_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(FordFulkerson_FromReadedCitHep);
BENCHMARK(FordFulkerson_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Kruskal_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ static void Kruskal_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(Kruskal_FromReadedCitHep);
BENCHMARK(Kruskal_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Node_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ static void NodeGetData(benchmark::State &state) {
n1.getData();
}
}
BENCHMARK(NodeGetData);
BENCHMARK(NodeGetData);
2 changes: 1 addition & 1 deletion benchmark/Partition_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ static void PartitionEBV_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(PartitionEBV_FromReadedCitHep);
BENCHMARK(PartitionEBV_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/Prim_BM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ static void Prim_FromReadedCitHep(benchmark::State &state) {
}
}

BENCHMARK(Prim_FromReadedCitHep);
BENCHMARK(Prim_FromReadedCitHep);
2 changes: 1 addition & 1 deletion benchmark/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <benchmark/benchmark.h>

BENCHMARK_MAIN();
BENCHMARK_MAIN();
2 changes: 1 addition & 1 deletion examples/DialExample/dial_example.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <math.h>
#include <memory>

#include <CXXGraph/CXXGraph.hpp>
#include <memory>

using std::make_shared;

Expand Down
1 change: 0 additions & 1 deletion examples/DijkstraExample/dijkstra_example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <CXXGraph/CXXGraph.hpp>

#include <memory>

using std::make_shared;
Expand Down
28 changes: 16 additions & 12 deletions examples/NetworkDynamicsExample/network_dynamics_example.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "CXXGraph/CXXGraph.hpp"

#include <memory>

#include "CXXGraph/CXXGraph.hpp"

using std::make_shared;

int main() {
Expand All @@ -25,23 +25,26 @@ int main() {

auto degreeMatrix = graph.getDegreeMatrix();
for (const auto& nodePair : *degreeMatrix) {
const CXXGraph::shared<const CXXGraph::Node<int>>& node = nodePair.first;
const std::vector<int>& degrees = nodePair.second;
const CXXGraph::shared<const CXXGraph::Node<int>>& node = nodePair.first;
const std::vector<int>& degrees = nodePair.second;

std::cout << "Node: " << node->getId() << ", Degree: " << degrees[0] << "\n";
}
std::cout << "Node: " << node->getId() << ", Degree: " << degrees[0]
<< "\n";
}
auto laplacianMatrix = graph.getLaplacianMatrix();
for (const auto& nodePair : *laplacianMatrix) {
const auto& node = nodePair.first;
const auto& neighbors = nodePair.second;

std::cout << "Node " << node->getId() << " connected to:" << std::endl;
for (const auto& neighbor : neighbors) {
if (neighbor.first == node) {
std::cout << " -> Itself" << std::endl;
} else {
std::cout << " -> Node " << neighbor.first->getId() << " with Edge ID " << (neighbor.second ? neighbor.second->getId() : -1) << std::endl;
}
if (neighbor.first == node) {
std::cout << " -> Itself" << std::endl;
} else {
std::cout << " -> Node " << neighbor.first->getId() << " with Edge ID "
<< (neighbor.second ? neighbor.second->getId() : -1)
<< std::endl;
}
}
std::cout << std::endl;
}
Expand All @@ -53,7 +56,8 @@ int main() {

std::cout << "Transitions from Node " << node->getId() << ":" << std::endl;
for (const auto& transition : transitions) {
std::cout << " -> To Node " << transition.first->getId() << " with Probability " << transition.second << std::endl;
std::cout << " -> To Node " << transition.first->getId()
<< " with Probability " << transition.second << std::endl;
}
std::cout << std::endl;
}
Expand Down
15 changes: 9 additions & 6 deletions examples/PartitionExample/partition_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ int main() {
// std::cout << *cit_graph_ptr << std::endl;
std::cout << cit_graph_ptr->getEdgeSet().size() << std::endl;
std::cout << cit_graph_ptr->getNodeSet().size() << std::endl;
auto partitionedTwo = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 2, 1, 1, 1, 4);
auto partitionedTwo =
CXXGraph::Partitioning::Partitioner<int>::partitionGraph(
*cit_graph_ptr, CXXGraph::Partitioning::HDRF_ALG, 2, 1, 1, 1, 4);
std::cout << "end partition two" << std::endl;
auto partitionedFour = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 4, 1, 1, 1, 4);
auto partitionedFour =
CXXGraph::Partitioning::Partitioner<int>::partitionGraph(
*cit_graph_ptr, CXXGraph::Partitioning::HDRF_ALG, 4, 1, 1, 1, 4);
std::cout << "end partition four" << std::endl;
auto partitionedEight = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 8, 1, 1, 1, 4);
auto partitionedEight =
CXXGraph::Partitioning::Partitioner<int>::partitionGraph(
*cit_graph_ptr, CXXGraph::Partitioning::HDRF_ALG, 8, 1, 1, 1, 4);
std::cout << "end partition eight" << std::endl;
auto statsTwo = CXXGraph::Partitioning::getPartitionStats(partitionedTwo);
auto statsFour = CXXGraph::Partitioning::getPartitionStats(partitionedFour);
Expand Down
7 changes: 4 additions & 3 deletions include/CXXGraph/Edge/DirectedEdge_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace CXXGraph {
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;
using shared = std::shared_ptr<T>;

template <typename T>
class UndirectedEdge;
Expand All @@ -48,8 +48,9 @@ class DirectedEdge : public Edge<T> {
shared<const Node<T>> node2);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
DirectedEdge(
const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
DirectedEdge(const Edge<T> &edge);
virtual ~DirectedEdge() = default;
const Node<T> &getFrom() const;
Expand Down
10 changes: 6 additions & 4 deletions include/CXXGraph/Edge/DirectedEdge_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@
#include "DirectedEdge_decl.h"

namespace CXXGraph {

using std::make_unique;

using std::make_shared;
using std::make_unique;

template <typename T>
DirectedEdge<T>::DirectedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2)
: Edge<T>(id, node1, node2) {}

template <typename T>
DirectedEdge<T>::DirectedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2) : Edge<T>(id, node1, node2) {}
DirectedEdge<T>::DirectedEdge(const CXXGraph::id_t id,
shared<const Node<T>> node1,
shared<const Node<T>> node2)
: Edge<T>(id, node1, node2) {}

template <typename T>
DirectedEdge<T>::DirectedEdge(
Expand Down
2 changes: 1 addition & 1 deletion include/CXXGraph/Edge/DirectedWeightedEdge_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace CXXGraph {
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;
using shared = std::shared_ptr<T>;

// Foward Declaration
template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion include/CXXGraph/Edge/DirectedWeightedEdge_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

namespace CXXGraph {

using std::make_unique;
using std::make_shared;
using std::make_unique;

template <typename T>
DirectedWeightedEdge<T>::DirectedWeightedEdge(const CXXGraph::id_t id,
Expand Down
7 changes: 4 additions & 3 deletions include/CXXGraph/Edge/Edge_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ using unique = std::unique_ptr<T>;
template <typename T>
using shared = std::shared_ptr<T>;


template <typename T>
class Edge;
// ostream operator
Expand All @@ -49,7 +48,8 @@ class Edge {

public:
Edge(const CXXGraph::id_t id, const Node<T> &node1, const Node<T> &node2);
Edge(const CXXGraph::id_t id, shared<const Node<T>> node1, shared<const Node<T>> node2);
Edge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2);
Edge(const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair);
Edge(const CXXGraph::id_t id,
Expand All @@ -58,7 +58,8 @@ class Edge {
void setFirstNode(shared<const Node<T>> node);
void setSecondNode(shared<const Node<T>> node);
const unsigned long long getId() const;
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &getNodePair() const;
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &getNodePair()
const;
shared<const Node<T>> getOtherNode(shared<const Node<T>> node) const;
virtual const std::optional<bool> isDirected() const;
virtual const std::optional<bool> isWeighted() const;
Expand Down
14 changes: 8 additions & 6 deletions include/CXXGraph/Edge/Edge_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ using unique = std::unique_ptr<T>;
template <typename T>
using shared = std::shared_ptr<T>;

using std::make_unique;
using std::make_shared;
using std::make_unique;

template <typename T>
Edge<T>::Edge(const CXXGraph::id_t id, const Node<T> &node1,
Expand All @@ -43,7 +43,8 @@ Edge<T>::Edge(const CXXGraph::id_t id, const Node<T> &node1,
}

template <typename T>
Edge<T>::Edge(const CXXGraph::id_t id, shared<const Node<T>> node1, shared<const Node<T>> node2) {
Edge<T>::Edge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2) {
this->nodePair.first = node1;
this->nodePair.second = node2;
this->id = id;
Expand All @@ -58,8 +59,9 @@ Edge<T>::Edge(const CXXGraph::id_t id,
}

template <typename T>
Edge<T>::Edge(const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair)
Edge<T>::Edge(
const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair)
: nodePair(nodepair) {
this->id = id;
}
Expand All @@ -82,8 +84,8 @@ const unsigned long long Edge<T>::getId() const {
}

template <typename T>
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &Edge<T>::getNodePair()
const {
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &
Edge<T>::getNodePair() const {
return nodePair;
}

Expand Down
7 changes: 4 additions & 3 deletions include/CXXGraph/Edge/UndirectedEdge_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace CXXGraph {
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;
using shared = std::shared_ptr<T>;

template <typename T>
class UndirectedEdge;
Expand All @@ -47,8 +47,9 @@ class UndirectedEdge : public Edge<T> {
shared<const Node<T>> node2);
UndirectedEdge(const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair);
UndirectedEdge(const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
UndirectedEdge(
const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
UndirectedEdge(const Edge<T> &edge);
virtual ~UndirectedEdge() = default;
const Node<T> &getNode1() const;
Expand Down
5 changes: 3 additions & 2 deletions include/CXXGraph/Edge/UndirectedEdge_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

namespace CXXGraph {

using std::make_unique;
using std::make_shared;
using std::make_unique;

template <typename T>
UndirectedEdge<T>::UndirectedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2)
: Edge<T>(id, node1, node2) {}

template <typename T>
UndirectedEdge<T>::UndirectedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
UndirectedEdge<T>::UndirectedEdge(const CXXGraph::id_t id,
shared<const Node<T>> node1,
shared<const Node<T>> node2)
: Edge<T>(id, node1, node2) {}

Expand Down
2 changes: 1 addition & 1 deletion include/CXXGraph/Edge/UndirectedWeightedEdge_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

namespace CXXGraph {

using std::make_unique;
using std::make_shared;
using std::make_unique;

template <typename T>
UndirectedWeightedEdge<T>::UndirectedWeightedEdge(const CXXGraph::id_t id,
Expand Down
Loading
Loading