.n个顶点的有向图用邻接矩阵array表示下面是其拓扑排序算法试补充完整
注().图的顶点号从 开始计 ().indegree 是有n个分量的一维数组放顶点的入度
().函数 crein 用于算顶点入度 ().有三个函数push(data)pop( )check( )其含义为数据 data进栈退栈和测试栈是否空(不空返回否则)
crein( array indegreen)
{ for (i=;i<n;i++) indegree[i]= (()_______)
for(i=i<n;i++)
for (j=;j<n; j++) indegree[i]+=array[()_______][()_______];
}
topsort (arrayindegreen)
{ count= (()_______)
for (i=;i<n;i++) if (()_______) push(i)
while (check( ))
{ vex=pop( ); printf(vex); count++;
for (i=;i<n;i++)
{ k=array()_______
if (()_______ ) { indegree[i]; if (()_______ ) push(i); }
}
}
if( count<n) printf(图有回路)
} 【南京理工大学 三 (分)】
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []