Skip to content

Commit 23cd6d9

Browse files
authored
Fix warnings in compilation of tests (#460)
* Add `Wall` and `Wextra` flags in compilation of tests * Fix warnings
1 parent 3c98352 commit 23cd6d9

17 files changed

+60
-51
lines changed

include/CXXGraph/Graph/Algorithm/BellmanFord_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const BellmanFordResult Graph<T>::bellmanford(const Node<T> &source,
6767
// iterations remain the same.
6868
auto earlyStopping = false;
6969
// outer loop for vertex relaxation
70-
for (int i = 0; i < n - 1; ++i) {
70+
for (size_t i = 0; i < n - 1; ++i) {
7171
auto edgeSet = Graph<T>::getEdgeSet();
7272
// inner loop for distance updates of
7373
// each relaxation

include/CXXGraph/Graph/Algorithm/BestFirstSearch_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ const std::vector<Node<T>> Graph<T>::concurrency_breadth_first_search(
209209

210210
// last worker need to do preparation for the next iteration
211211
int cur_level = level;
212-
if (num_threads == 1 + waiting_workers.fetch_add(1)) {
212+
if (num_threads == 1u + waiting_workers.fetch_add(1u)) {
213213
swap(level_tracker, next_level_tracker);
214214
next_level_tracker.clear();
215215

@@ -240,7 +240,7 @@ const std::vector<Node<T>> Graph<T>::concurrency_breadth_first_search(
240240
};
241241

242242
std::vector<std::thread> workers;
243-
for (int i = 0; i < num_threads - 1; ++i) {
243+
for (size_t i = 0; i < num_threads - 1; ++i) {
244244
workers.emplace_back(std::thread(bfs_worker));
245245
}
246246
bfs_worker();

include/CXXGraph/Graph/Algorithm/Connectivity_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool Graph<T>::isConnectedGraph() const {
4343
visited[source->getId()] = true;
4444

4545
// travel the neighbors
46-
for (int i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
46+
for (size_t i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
4747
shared<const Node<T>> neighbor =
4848
(*cachedAdjMatrix)[source].at(i).first;
4949
if (visited[neighbor->getId()] == false) {
@@ -83,7 +83,7 @@ bool Graph<T>::isStronglyConnectedGraph() const {
8383
visited[source->getId()] = true;
8484

8585
// travel the neighbors
86-
for (int i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
86+
for (size_t i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
8787
shared<const Node<T>> neighbor =
8888
(*cachedAdjMatrix)[source].at(i).first;
8989
if (visited[neighbor->getId()] == false) {
@@ -106,4 +106,4 @@ bool Graph<T>::isStronglyConnectedGraph() const {
106106
}
107107
}
108108
} // namespace CXXGraph
109-
#endif // __CXXGRAPH_CONNECTIVITY_IMPL_H__
109+
#endif // __CXXGRAPH_CONNECTIVITY_IMPL_H__

include/CXXGraph/Graph/Algorithm/Dial_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const DialResult Graph<T>::dial(const Node<T> &source, int maxWeight) const {
6565
B[0].push_back(*source_node_it);
6666
dist[*source_node_it].first = 0;
6767

68-
int idx = 0;
68+
std::size_t idx = 0;
6969
while (true) {
7070
// Go sequentially through buckets till one non-empty
7171
// bucket is found

include/CXXGraph/Graph/Algorithm/Dijkstra_impl.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const DijkstraResult Graph<T>::dijkstra(const Node<T>& source,
5151
return result;
5252
}
5353
// n denotes the number of vertices in graph
54-
auto n = cachedAdjMatrix->size();
54+
// unused
55+
//auto n = cachedAdjMatrix->size();
5556

5657
// setting all the distances initially to INF_DOUBLE
5758
std::unordered_map<shared<const Node<T>>, double, nodeHash<T>> dist;
@@ -175,7 +176,8 @@ const DijkstraResult Graph<T>::dijkstra_deterministic(
175176
return result;
176177
}
177178
// n denotes the number of vertices in graph
178-
auto n = cachedAdjMatrix->size();
179+
// unused
180+
//auto n = cachedAdjMatrix->size();
179181

180182
// setting all the distances initially to INF_DOUBLE
181183
std::unordered_map<shared<const Node<T>>, double, nodeHash<T>> dist;
@@ -322,7 +324,8 @@ const DijkstraResult Graph<T>::dijkstra_deterministic2(
322324
return result;
323325
}
324326
// n denotes the number of vertices in graph
325-
auto n = cachedAdjMatrix->size();
327+
// unused
328+
// auto n = cachedAdjMatrix->size();
326329

327330
// setting all the distances initially to INF_DOUBLE
328331
std::unordered_map<shared<const Node<T>>, double, nodeHash<T>> dist;

include/CXXGraph/Graph/Algorithm/Kosaraju_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SCCResult<T> Graph<T>::kosaraju() const {
5151
visited[source->getId()] = true;
5252

5353
// travel the neighbors
54-
for (int i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
54+
for (size_t i = 0; i < (*cachedAdjMatrix)[source].size(); i++) {
5555
shared<const Node<T>> neighbor =
5656
(*cachedAdjMatrix)[source].at(i).first;
5757
if (visited[neighbor->getId()] == false) {
@@ -99,7 +99,7 @@ SCCResult<T> Graph<T>::kosaraju() const {
9999
result.sccMap[source->getId()] = sccLabel;
100100

101101
// travel the neighbors
102-
for (int i = 0; i < rev[source].size(); i++) {
102+
for (size_t i = 0; i < rev[source].size(); i++) {
103103
shared<const Node<T>> neighbor = rev[source].at(i).first;
104104
if (visited[neighbor->getId()] == false) {
105105
// make recursive call from neighbor
@@ -125,4 +125,4 @@ SCCResult<T> Graph<T>::kosaraju() const {
125125
}
126126
}
127127
} // namespace CXXGraph
128-
#endif // __CXXGRAPH_KOSARAJU_IMPL_H__
128+
#endif // __CXXGRAPH_KOSARAJU_IMPL_H__

include/CXXGraph/Graph/Algorithm/Prim_impl.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const MstResult Graph<T>::prim() const {
4141
return result;
4242
}
4343
auto nodeSet = Graph<T>::getNodeSet();
44-
auto n = nodeSet.size();
44+
// unused
45+
/* auto n = nodeSet.size(); */
4546

4647
// setting all the distances initially to INF_DOUBLE
4748
std::unordered_map<shared<const Node<T>>, double, nodeHash<T>> dist;
@@ -109,4 +110,4 @@ const MstResult Graph<T>::prim() const {
109110
return result;
110111
}
111112
} // namespace CXXGraph
112-
#endif // __CXXGRAPH_PRIM_IMPL_H__
113+
#endif // __CXXGRAPH_PRIM_IMPL_H__

include/CXXGraph/Graph/Graph_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ std::shared_ptr<std::vector<Node<T>>> Graph<T>::eulerianPath() const {
463463
std::shared_ptr<std::vector<Node<T>>> eulerPath =
464464
std::make_shared<std::vector<Node<T>>>();
465465

466-
bool undirected = this->isUndirectedGraph();
466+
// unused
467+
// bool undirected = this->isUndirectedGraph();
467468

468469
std::vector<shared<const Node<T>>> currentPath;
469470
// The starting node is the only node which has more outgoing than ingoing

include/CXXGraph/Graph/IO/InputOperation_impl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ int Graph<T>::readFromMTXFile(const std::string &workingDir,
181181
}
182182

183183
// Define the number of columns and rows in the matrix
184-
int n_cols, n_rows;
185-
int n_edges;
184+
std::size_t n_cols, n_rows;
185+
std::size_t n_edges;
186186
bool undirected = false;
187187

188188
// From the first line of the file read the number of rows, columns and edges
@@ -201,11 +201,11 @@ int Graph<T>::readFromMTXFile(const std::string &workingDir,
201201
std::stringstream header_stream(row_content);
202202
std::string value;
203203
getline(header_stream, value, ' ');
204-
n_rows = std::stoi(value);
204+
n_rows = std::stoul(value);
205205
getline(header_stream, value, ' ');
206-
n_cols = std::stoi(value);
206+
n_cols = std::stoul(value);
207207
getline(header_stream, value, ' ');
208-
n_edges = std::stoi(value);
208+
n_edges = std::stoul(value);
209209

210210
// Since the matrix represents the adjacency matrix, it must be square
211211
if (n_rows != n_cols) {
@@ -434,4 +434,4 @@ void Graph<T>::recreateGraph(
434434
}
435435

436436
} // namespace CXXGraph
437-
#endif // __CXXGRAPH_INPUTOPERATION_IMPL_H__
437+
#endif // __CXXGRAPH_INPUTOPERATION_IMPL_H__

include/CXXGraph/Graph/IO/OutputOperation_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ int Graph<T>::writeToFile(InputOutputFormat format,
124124
return _result;
125125
};
126126
if (format == InputOutputFormat::STANDARD_CSV) {
127-
auto result = _compress(".csv");
127+
result = _compress(".csv");
128128
} else if (format == InputOutputFormat::STANDARD_TSV) {
129-
auto result = _compress(".tsv");
129+
result = _compress(".tsv");
130130
} else {
131131
// OUTPUT FORMAT NOT RECOGNIZED
132132
result = -1;
@@ -285,4 +285,4 @@ void Graph<T>::writeGraphToStream(std::ostream &oGraph, std::ostream &oNodeFeat,
285285
}
286286

287287
} // namespace CXXGraph
288-
#endif // __CXXGRAPH_OUTPUTOPERATION_IMPL_H__
288+
#endif // __CXXGRAPH_OUTPUTOPERATION_IMPL_H__

0 commit comments

Comments
 (0)