資源描述:
《關鍵 路徑代碼算法》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在教育資源-天天文庫。
1、#include#include#definestack_max_size100#definestack_extra10typedefstruct{int*top;int*base;intstacksize;}vexstack,*pvexstack;intinitstack(vexstack&st){st.base=(int*)malloc(stack_max_size*sizeof(int));if(!st.base)exit(0);st.top=st.base;st.
2、stacksize=stack_max_size;return1;}intpop(vexstack&st,int&a){if(st.top==st.base)return0;a=*(--st.top);return1;}intpush(vexstack&st,inta){if(st.top-st.base>=st.stacksize){st.base=(int*)realloc(st.base,(stack_max_size+stack_extra)*sizeof(int));if(!st.base)exit
3、(0);st.top=st.base+st.stacksize;st.stacksize+=stack_extra;}*st.top++=a;return1;}intdestroystack(vexstack&st){free(st.base);return1;}intemptystack(vexstackst){if(st.top==st.base)return1;elsereturn0;}typedefstructnarc{intadjvex;intinfo;}narc,*pnarc;typedefstr
4、uctheadvexter{intindegree;intkaiguan;intoutdegree;chardata;pnarcoutarc;}headvexter,*pheadvexter;typedefstruct{intvexnum;pheadvextervexs;}graph,*pgraph;voidinitgraph(graph&G){inti=0,j,k=0,n,l=0;charc[100];printf("請輸入有向圖的節(jié)點:");gets(c);while(c[i]!='