数据结构有向无环图-其应用.pptVIP

  • 6
  • 0
  • 约1.88千字
  • 约 36页
  • 2017-04-26 发布于四川
  • 举报
数据结构有向无环图-其应用

有向无环图 及其应用;一、定义;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;二、拓扑排序;Status TopologicalSort(ALGraph){ FindIndegree(G,indegree); InitStack(S); for (i=0;iG.vexnum;++i) if (!indegree[i]) Push(S,i); //入度为0的顶点的序号进栈 count =0; while (!StackEmpty(S)){ Pop(S,i); couti G.vertices[i].data; ++count; for (p=G.vertices[i].firstarc; p; p=p-nextarc){ k=p-adjvex; --indegree[k]; if (!(indegree[k])) Push(S,k) ; };Status TopologicalSort(ALGraph){ FindIndegree(G,indegree); InitStack(S); for (i=0;iG.vexnum;++i) if (!indegree[i]) Push(S,i); //入度为0的顶点的序号进栈 count =0; while (!StackEmpty(S)){ Pop(S,i); couti G.vertices[i].data; ++count; for (p=G.vertices[i].firstarc; p; p=p-nextarc){ k=p-adjvex; --indegree[k]; if (!(indegree[k])) Push(S,k) ; } }//while if (count= =G.vexnum) return OK; else return ERROR; }//TopologicalSort;Status TopologicalSort(ALGraph){ FindIndegree(G,indegree); InitStack(S); for (i=0;iG.vexnum;++i) if (!indegree[i]) Push(S,i); //入度为0的顶点的序号进栈 count =0; while (!StackEmpty(S)){ Pop(S,i); couti G.vertices[i].data; ++count; for (p=G.vertices[i].firstarc; p; p=p-nextarc){ k=p-adjvex; --indegree[k]; if (!(indegree[k])) Push(S,k) ; } }//while if (count= =G.vexnum) return OK; else return ERROR; }//TopologicalSort;三、关键路径;三、关键路径;三、关键路径;三、关键路径;三、关键路径;作业:;作业:;End

文档评论(0)

1亿VIP精品文档

相关文档