【正文】
i++) if([i].key==k)return i。} SSTable。/* Index the element which key is k *//* in StaticSearchTable s. *//* Return 0 if x is not found. */靜態(tài)查找表的類型SSTable定義如下:typedef struct { KeyType key。 !visited[v]) sum+=SimplePath(G,v,j,k1)。 for(v=0。k==1 amp。 // 圖的種類標(biāo)志}MGraph。typedef struct { AdjMatrix arcs。 // 有向圖,有向網(wǎng),無向圖,無向網(wǎng)typedef struct { VRType adj。 if(!visited[w]) DFS2(dig,w,scc,j,k)。 scc[j][k++]=[v].data。 }void DFS2(OLGraph dig,int v,StrARR amp。p。 } }}void DFS1(OLGraph dig,int v){ int w。i=0。 for(v=0。 count=0。scc,int j,int k)。} OLGraph。 ArcBox *firstin,*firstout。 // 記錄各強(qiáng)連通分量typedef struct ArcBox { int tailvex,headvex。n)。 } AllPath2(g,sv,tv,path,i,d,A)。l++) { strcpy(B,path[l])。i)/* Get all the paths from vertex sv to tv, save them *//* into Array path which contains string ponents. *//* Return the number of path using i */{ int d=0,j,l。 } visited[j]=0。 } else for(p=[j].firstarc。 for(n=0。 j=LocateVex(g,sv)。path, int amp。v39。 to 39。int LocateVex(Graph g, VertexType v)。} VNode, AdjList[MAX_VERTEX_NUM]。 struct ArcNode *nextarc。/* Get all the paths from vertex sv to tv, save them *//* into Array path which contains string ponents. *//* Return the number of path using i */圖的鄰接表以及相關(guān)類型、函數(shù)和輔助變量定義如下:Status visited[MAX_VERTEX_NUM]。 }}⑤ 已知有向圖和圖中兩個(gè)頂點(diǎn)u和v,試編寫算法求有向圖中從u到v的所有簡(jiǎn)單路徑。p=pnextarc) { l=padjvex。 visited[i]=1。amp。path39。path, VertexType v)。v39。int LocateVex(Graph g, VertexType v)。} VNode, AdjList[MAX_VERTEX_NUM]。 struct ArcNode *nextarc。/* Judge whether it exists a path from sv to tv with length k *//* in graph g, return path using string sp if exists. */圖的鄰接表以及相關(guān)類型、函數(shù)和輔助變量定義如下:Status visited[MAX_VERTEX_NUM]。 Push(s,p)。 flag=1。flag=0。visit(v0)。 if(amp。void Traverse(Graph dig, VertexType v0, void (*visit)(VertexType)) { int i,v,flag。x)。Status Push(SStack