Skip to content

Conversation

@MinyazevR
Copy link
Owner

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

typedef struct Node
{
int index;
int lenght;

Choose a reason for hiding this comment

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

Она length

newGraph->nodes = calloc(numberOfNode, sizeof(Node*));
for (int i = 0; i < numberOfNode; i++)
{
newGraph->nodes[i] = calloc(1, sizeof(int*));

Choose a reason for hiding this comment

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

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

return newGraph;
}

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

Choose a reason for hiding this comment

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

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


void printMatrix(Graph* graph)
{
for (int i = 0; i < 6; i++)

Choose a reason for hiding this comment

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

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

{
int numberOfSegments;
struct List** array;
} Table;

Choose a reason for hiding this comment

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

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

}
}
}
}

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.

3 participants