void InitGraph(GraphList *G) /*初始化圖*/
{
int i,vexnum,arcnum,weight=0;
int v1,v2;
EdgeList p;
printf("Please input the vertexnum and the arcnum-->Form:(x,y)\n");
scanf("%d,%d",&vexnum,&arcnum);
G->vexnum=vexnum;
G->arcnum=arcnum;
for(i=0;i<vexnum;i++)
{
G->vexs[i].vertex=i+1;
G->vexs[i].edgelist=NULL;
}
for(i=0;i<arcnum;i++)
{
printf("Please input The %d Edge (For Examp: 1,2,10)\n",i+1);
scanf("%d,%d,%d",&v1,&v2,&weight);
if(v1>G->vexnum||v2>G->vexnum)
{
printf("The Node You Hava Input Is Not In The Vexs!!");
getch();
exit(0);
}
p=(EdgeList)malloc(sizeof(EdgeNode));
p->endvex=v2;
p->weight=weight;
p->nextedge=G->vexs[v1].edgelist;
G->vexs[v1].edgelist=p;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/242595.html
標籤:C語言
上一篇:怎么發帖啊?
下一篇:二分查找。。。求教...
