Skip to content

Homework - #5

Open
VariPor wants to merge 35 commits into
DafeMipt213:mainfrom
VariPor:homework
Open

Homework#5
VariPor wants to merge 35 commits into
DafeMipt213:mainfrom
VariPor:homework

Conversation

@VariPor

@VariPor VariPor commented Nov 25, 2023

Copy link
Copy Markdown

No description provided.

Comment thread task_01/src/topology_sort.cpp Outdated
Comment thread task_01/src/topology_sort.cpp Outdated
Comment thread task_02/src/bridge_search.cpp Outdated
Comment thread task_02/src/search.hpp Outdated
Comment thread task_03/src/Johnson_alg.cpp Outdated
Comment thread task_03/src/Johnson_alg.cpp Outdated
Comment thread task_04/src/Dijkstra_alg.hpp Outdated
Comment thread task_05/src/RMQ.hpp Outdated
Comment thread task_06/src/LCA.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 48. Check the log or trigger a new build to see more.

if (visited[ver] == true) return;
visited[ver] = true;
for (std::size_t i = 0; i < graph[ver].size(); ++i) {
int destination = graph[ver][i];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'destination' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int destination = graph[ver][i];
int const destination = graph[ver][i];

stack_ver.push(ver);
}

Vertexes TopologySort(Graph graph) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Suggested change
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'destination' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
                                             ^

Comment thread task_05/src/RMQ.cpp
}

RmqSolver::RmqSolver(const std::vector<int>& data) {
sparse_table = std::vector<std::vector<int>>(GetLog(data.size()) + 1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
                                                      ^

Comment thread task_05/src/RMQ.cpp
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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
          ^

Comment thread task_05/src/RMQ.cpp
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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
                                   ^

Comment thread task_05/src/RMQ.cpp
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)])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)])
                                                  ^

Comment thread task_05/src/RMQ.cpp
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)])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше инициализировать переменные. тут если distances в строке 26 неопределенное поведение

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants