DFS,拓扑排序

DFS伪代码:

DFS(G,s)
    for each vertex v in V(G)
        status[v] = WHITE
        /******其他初始化******/
    for each vertex v in V(G)
        if(status[v]==WHITE)
            DFS-VISIT(v)
 
DFS-VISIT(v)
    status[v] = GRAY
    for each vertex t in Adj(v)
        if status[t] = WHITE
            DFS-VISIT(t)
            /******其他操作******/
    status[v] = BLACK

关于DFS的C语言版和拓扑排序以及是否存在环,引用一位大牛的博客:

http://blog.csdn.net/acceptedxukai/article/details/6959882

    原文作者:拓扑排序
    原文地址: https://blog.csdn.net/a_big_pig/article/details/44180227
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞