Homework - #5
Conversation
Homework
| if (visited[ver] == true) return; | ||
| visited[ver] = true; | ||
| for (std::size_t i = 0; i < graph[ver].size(); ++i) { | ||
| int destination = graph[ver][i]; |
There was a problem hiding this comment.
warning: variable 'destination' of type 'int' can be declared 'const' [misc-const-correctness]
| int destination = graph[ver][i]; | |
| int const destination = graph[ver][i]; |
| stack_ver.push(ver); | ||
| } | ||
|
|
||
| Vertexes TopologySort(Graph graph) { |
There was a problem hiding this comment.
warning: the parameter 'graph' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
task_01/src/topology_sort.hpp:7:
- Vertexes TopologySort(Graph graph);
+ Vertexes TopologySort(const Graph& graph);| Vertexes TopologySort(Graph graph) { | |
| Vertexes TopologySort(const Graph& graph) { |
| std::vector<bool> visited; | ||
| visited = std::vector<bool>(graph.size()); | ||
| for (std::size_t i = 0; i < graph.size(); ++i) { | ||
| Dfs(i, result_dfs, graph, visited); |
There was a problem hiding this comment.
warning: narrowing conversion from 'std::size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
Dfs(i, result_dfs, graph, visited);
^| t_up[v] = timer; | ||
| timer += 1; | ||
| for (std::size_t i = 0; i < graph.at(v).size(); ++i) { | ||
| int destination = graph.at(v).at(i); |
There was a problem hiding this comment.
warning: variable 'destination' of type 'int' can be declared 'const' [misc-const-correctness]
| int destination = graph.at(v).at(i); | |
| int const destination = graph.at(v).at(i); |
| for (std::size_t i = 0; i < graph.size(); ++i) | ||
| for (std::size_t j = 0; j < graph.at(i).size(); ++j) { | ||
| new_graph[i].push_back(graph.at(i).at(j)); | ||
| new_graph[graph.at(i).at(j)].push_back(i); |
There was a problem hiding this comment.
warning: narrowing conversion from 'std::size_t' (aka 'unsigned long') to signed type 'value_type' (aka 'int') is implementation-defined [cppcoreguidelines-narrowing-conversions]
new_graph[graph.at(i).at(j)].push_back(i);
^| } | ||
|
|
||
| RmqSolver::RmqSolver(const std::vector<int>& data) { | ||
| sparse_table = std::vector<std::vector<int>>(GetLog(data.size()) + 1, |
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]
sparse_table = std::vector<std::vector<int>>(GetLog(data.size()) + 1,
^| sparse_table[0] = data; | ||
| for (size_t i = 1; i < sparse_table.size(); ++i) | ||
| for (size_t j = 0; j < data.size(); ++j) | ||
| if (j + std::pow(2, i - 1) < data.size()) |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') [cppcoreguidelines-narrowing-conversions]
if (j + std::pow(2, i - 1) < data.size())
^| sparse_table[0] = data; | ||
| for (size_t i = 1; i < sparse_table.size(); ++i) | ||
| for (size_t j = 0; j < data.size(); ++j) | ||
| if (j + std::pow(2, i - 1) < data.size()) |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') [cppcoreguidelines-narrowing-conversions]
if (j + std::pow(2, i - 1) < data.size())
^| for (size_t j = 0; j < data.size(); ++j) | ||
| if (j + std::pow(2, i - 1) < data.size()) | ||
| sparse_table[i][j] = (sparse_table[i - 1][j] < | ||
| sparse_table[i - 1][j + std::pow(2, i - 1)]) |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') [cppcoreguidelines-narrowing-conversions]
sparse_table[i - 1][j + std::pow(2, i - 1)])
^| for (size_t j = 0; j < data.size(); ++j) | ||
| if (j + std::pow(2, i - 1) < data.size()) | ||
| sparse_table[i][j] = (sparse_table[i - 1][j] < | ||
| sparse_table[i - 1][j + std::pow(2, i - 1)]) |
There was a problem hiding this comment.
warning: narrowing conversion from 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
sparse_table[i - 1][j + std::pow(2, i - 1)])
^|
|
||
| bool FordBellmanAlgorithm(const std::vector<Edge>& graph, | ||
| std::vector<int>& distances) { | ||
| int temp_vertex; |
There was a problem hiding this comment.
лучше инициализировать переменные. тут если distances в строке 26 неопределенное поведение
No description provided.