Skip to content

AStar#5

Open
Half-Head wants to merge 11 commits intoDafeCpp:mainfrom
Half-Head:tyoma
Open

AStar#5
Half-Head wants to merge 11 commits intoDafeCpp:mainfrom
Half-Head:tyoma

Conversation

@Half-Head
Copy link
Copy Markdown

No description provided.

@LostPointer
Copy link
Copy Markdown
Contributor

форматирование упало(

std::vector<std::pair<float, float>> coords)
: Description(adjList), Coordinates(coords) {}

std::vector<Edge> Neighbors(int vertex) { return Description[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.

давай вернем const std::vector&

и метод можно сделать const

came_from.assign(n, -1);
closed.assign(n, false);

gscore[from_] = 0;
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.

сейчас если from_/to_ вне диапазона, будет UB/краш

Comment thread lib/src/util.hpp
Comment thread lib/src/util.hpp Outdated
if (weighted) {
weightedDescription = adjList;
} else {
throw("Use other constructor for unweighted graph");
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.

тут получается что кидаешь указатель на char, давай поправим


std::vector<Edge> Neighbors(int vertex) { return Description[vertex]; }

std::pair<float, float> GetCoordinates(int 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.

и этот тоже можно сделать const

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.

а это?)

Copy link
Copy Markdown
Contributor

@LostPointer LostPointer left a comment

Choose a reason for hiding this comment

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

для автомата нужно найти еще 1 бал где-то мст не обязательно доделывать, но остальное хорошо бы, пока 9 баллов


std::vector<Edge> Neighbors(int vertex) { return Description[vertex]; }

std::pair<float, float> GetCoordinates(int 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.

а это?)

Comment thread lib/src/util.cpp
bridges.clear();
currentTimer = 0;

dfs(0, -1, DfsMode::Bridges);
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.

DFS запускается только из вершины 0. Для несвязного графа нужно обходить все компоненты связности

Comment thread task_01/src/test.cpp
return edge;
}

TEST(BridgesTest, SimpleChain) {
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.

есть мосты, но где точки сочленения?

Comment thread task_03/src/test.cpp
ASSERT_EQ(1, 1); // Stack []
#include "../../lib/src/util.hpp"

TEST(Test, Seminar) {
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.

а проверка на то что граф содержит цикл?

Comment thread lib/src/util.cpp

std::vector<long long> Graph::BellmanFord(int source) {
int allVertex = weightedDescription.size();
long long INF = 9000000000000000000;
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.

std::numeric_limits::max()

Comment thread lib/src/util.cpp

if (parent[sink] == -1) break;

int pathFlow = 1000000000;
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.

std::numeric_limits::max()

Comment thread lib/src/util.cpp
return maxFlow;
}

long long Graph::DegreeConstrainedMST(int maxDegree) {
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.

Жадный алгоритм может не найти решение, даже если оно существует. Например, если жадный выбор приводит к ситуации, когда остались вершины со степенью d, но их нельзя соединить.

Граф: 1-2 (вес 1), 2-3 (вес 1), 1-3 (вес 100), d=1
Жадный алгоритм выберет 1-2 и 2-3, но тогда вершина 2 имеет степень 2 > d=1.
Правильное решение: 1-2 и 1-3 (но это дороже).

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