摘要: 1. 拓扑排序主要有两种算法:方法1:《算法导论》上给出的DFS+时间戳;方法2:求顶点入度+贪心算法。2. 两种算法的代码分别如下:View Code 1 static int f[100]={0}; 2 static int ftime=0; 3 //递归深度优先搜索 4 template<typename vertexNametype, typename weight> 5 void ALGraph<vertexNametype, weight>::DFS() 6 { 7 int n=getVertexNumber(); 8 bool *visited=... 阅读全文
posted @ 2012-07-12 12:32 kasuosuo 阅读(1366) 评论(0) 推荐(0) 编辑