algoritmhms_2nd - #17
Conversation
| @@ -1,8 +1,38 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| std::vector<int> Graph::topologicalSort() { | ||
| std::vector<int> inDegree(vertices, 0); | ||
| for (int u = 0; u < vertices; ++u) { | ||
| for (int v : adjList[u]) { |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| for (int v : adjList[u]) { | |
| for (int const v : adjList[u]) { |
|
|
||
| std::vector<int> result; | ||
| while (!q.empty()) { | ||
| int u = q.front(); |
There was a problem hiding this comment.
warning: variable 'u' of type 'int' can be declared 'const' [misc-const-correctness]
| int u = q.front(); | |
| int const u = q.front(); |
| q.pop(); | ||
| result.push_back(u); | ||
|
|
||
| for (int v : adjList[u]) { |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| for (int v : adjList[u]) { | |
| for (int const v : adjList[u]) { |
| const int INF = std::numeric_limits<int>::max(); | ||
|
|
||
| JohnsonAlgorithm::JohnsonAlgorithm(const std::vector<std::vector<int>>& g) | ||
| : graph(g), numVertices(g.size()) {} |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
: graph(g), numVertices(g.size()) {}
^| #include <cmath> | ||
|
|
||
| Solution::Solution(std::vector<std::vector<int>> &data, int root) { | ||
| int size = data.size(); |
There was a problem hiding this comment.
warning: variable 'size' of type 'int' can be declared 'const' [misc-const-correctness]
| int size = data.size(); | |
| int const size = data.size(); |
| #include <cmath> | ||
|
|
||
| Solution::Solution(std::vector<std::vector<int>> &data, int root) { | ||
| int size = data.size(); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
int size = data.size();
^| int size = data.size(); | ||
| eulerian_tour_position_.assign(size, -1); | ||
| heights_.assign(size, 0); | ||
| eulerian_tour_.reserve(2 * size); |
There was a problem hiding this comment.
warning: performing an implicit widening conversion to type 'size_type' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
eulerian_tour_.reserve(2 * size);
^Additional context
task_06/src/lca.cpp:7: make conversion explicit to silence this warning
eulerian_tour_.reserve(2 * size);
^task_06/src/lca.cpp:7: perform multiplication in a wider type
eulerian_tour_.reserve(2 * size);
^| heights_.assign(size, 0); | ||
| eulerian_tour_.reserve(2 * size); | ||
|
|
||
| adjacency_list_ = data; |
There was a problem hiding this comment.
warning: 'adjacency_list_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_06/src/lca.cpp:3:
- Solution::Solution(std::vector<std::vector<int>> &data, int root) {
+ Solution::Solution(std::vector<std::vector<int>> &data, int root) : adjacency_list_(data) {| adjacency_list_ = data; | |
|
|
||
| adjacency_list_ = data; | ||
|
|
||
| parent_.assign(size, std::vector<int>(log2(size) + 1, -1)); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
parent_.assign(size, std::vector<int>(log2(size) + 1, -1));
^
No description provided.