Skip to content

Задача 2#70

Open
MinyazevR wants to merge 1 commit intomainfrom
TestGraph
Open

Задача 2#70
MinyazevR wants to merge 1 commit intomainfrom
TestGraph

Conversation

@MinyazevR
Copy link
Copy Markdown
Owner

Здравствуйте, здесь ничего не работает, но я попытался написать хоть что-то за оставшееся время

Comment thread Test2/Graph/Graph/Graph.c
typedef struct Node
{
int index;
int lenght;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Она length

Comment thread Test2/Graph/Graph/Graph.c
newGraph->nodes = calloc(numberOfNode, sizeof(Node*));
for (int i = 0; i < numberOfNode; i++)
{
newGraph->nodes[i] = calloc(1, sizeof(int*));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sizeof(int*) тут очень внезапно, sizeof(Node) имелось в виду, скорее всего

Comment thread Test2/Graph/Graph/Graph.c
return newGraph;
}

void edgeLength(Graph* graph, int firstVertex, int secondVertex, int lenght)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Я бы её назвал как setEdgeLength или что-то такое, чтобы это была повелительная форма

Comment thread Test2/Graph/Graph/Graph.c

void printMatrix(Graph* graph)
{
for (int i = 0; i < 6; 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.

nodesCount вместо 6, скорее всего

Comment thread Test2/Graph/Graph/Graph.c
{
int numberOfSegments;
struct List** array;
} Table;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Объявления типов лучше сверху все

Comment thread Test2/Graph/Graph/Graph.c
}
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Как я понял, это сильно недописанная попытка сделать dfs. Но если он рекурсивный, то list (очередь рассматриваемых вершин?) не нужен, мы ходим просто по соседям, а если нерекурсивный, то не нужен рекурсивный вызов. И в любом случае, нужно множество уже посещённых вершин. И тогда вся задача своидтся к "пока есть непосещённые вершины, берём первую из них, гоним dfs, все посещённые при этом вершины складываем в новую компоненту связности"

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