Conversation
|
форматирование упало( |
| std::vector<std::pair<float, float>> coords) | ||
| : Description(adjList), Coordinates(coords) {} | ||
|
|
||
| std::vector<Edge> Neighbors(int vertex) { return Description[vertex]; } |
There was a problem hiding this comment.
давай вернем const std::vector&
и метод можно сделать const
| came_from.assign(n, -1); | ||
| closed.assign(n, false); | ||
|
|
||
| gscore[from_] = 0; |
There was a problem hiding this comment.
сейчас если from_/to_ вне диапазона, будет UB/краш
| if (weighted) { | ||
| weightedDescription = adjList; | ||
| } else { | ||
| throw("Use other constructor for unweighted graph"); |
There was a problem hiding this comment.
тут получается что кидаешь указатель на char, давай поправим
|
|
||
| std::vector<Edge> Neighbors(int vertex) { return Description[vertex]; } | ||
|
|
||
| std::pair<float, float> GetCoordinates(int vertex) { |
There was a problem hiding this comment.
и этот тоже можно сделать const
LostPointer
left a comment
There was a problem hiding this comment.
для автомата нужно найти еще 1 бал где-то мст не обязательно доделывать, но остальное хорошо бы, пока 9 баллов
|
|
||
| std::vector<Edge> Neighbors(int vertex) { return Description[vertex]; } | ||
|
|
||
| std::pair<float, float> GetCoordinates(int vertex) { |
| bridges.clear(); | ||
| currentTimer = 0; | ||
|
|
||
| dfs(0, -1, DfsMode::Bridges); |
There was a problem hiding this comment.
DFS запускается только из вершины 0. Для несвязного графа нужно обходить все компоненты связности
| return edge; | ||
| } | ||
|
|
||
| TEST(BridgesTest, SimpleChain) { |
There was a problem hiding this comment.
есть мосты, но где точки сочленения?
| ASSERT_EQ(1, 1); // Stack [] | ||
| #include "../../lib/src/util.hpp" | ||
|
|
||
| TEST(Test, Seminar) { |
There was a problem hiding this comment.
а проверка на то что граф содержит цикл?
|
|
||
| std::vector<long long> Graph::BellmanFord(int source) { | ||
| int allVertex = weightedDescription.size(); | ||
| long long INF = 9000000000000000000; |
There was a problem hiding this comment.
std::numeric_limits::max()
|
|
||
| if (parent[sink] == -1) break; | ||
|
|
||
| int pathFlow = 1000000000; |
There was a problem hiding this comment.
std::numeric_limits::max()
| return maxFlow; | ||
| } | ||
|
|
||
| long long Graph::DegreeConstrainedMST(int maxDegree) { |
There was a problem hiding this comment.
Жадный алгоритм может не найти решение, даже если оно существует. Например, если жадный выбор приводит к ситуации, когда остались вершины со степенью d, но их нельзя соединить.
Граф: 1-2 (вес 1), 2-3 (вес 1), 1-3 (вес 100), d=1
Жадный алгоритм выберет 1-2 и 2-3, но тогда вершина 2 имеет степень 2 > d=1.
Правильное решение: 1-2 и 1-3 (но это дороже).
No description provided.