#dfs topology sort problem

6 messages · Page 1 of 1 (latest)

astral scaffold
#
    visited[v] = true;
    struct LofLs *horizontal_pointer = start->nastepny;
    while(horizontal_pointer) {
        if (!visited[horizontal_pointer->pion]){
            dfs(horizontal_pointer->pion, visited, Stack, horizontal_pointer);}
        horizontal_pointer = horizontal_pointer->nastepny;
    }
    Stack.push(v);
    faza1[v]=(sprawdzanie++);
}
void tsort(struct LofLs *start, int n)
{
    stack<int> Stack;
    bool visited[n];
    for (int i = 0; i < n; i++)
        visited[i] = false;
    while (start) {
        if (!visited[start->pion])
            dfs(start->pion, visited, Stack, start);
        start = start->dol;
    }
    while (!Stack.empty()) {
        cout << Stack.top() << " ";
        faza2[Stack.top()]=(sprawdzanie++);
        Stack.pop();
    }
}``` here's bad sorting sometimes, i know why, bcs its not completed dfs(this is using list of succecors), how can i fix it?
naive hazelBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

soft elbow
#

if you know why, then which part are you still unclear how to fix?

astral scaffold
#

its hard

#

but i resolved it

#

!solved