1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| void create_graph(Graph &G) { printf("当前图G所包含的顶点为:\n"); VertexType v; scanf("%d",&v); while(v!=999) { addVertex(G,v); scanf("%d",&v); }
printf("请输入要创建的G的边集(V1 V2)\n"); VertexType v1,v2; scanf("%d%d",&v1,&v2); while(v1!=0||v2!=0) { add_edge(G,v1,v2); add_edge(G,v2,v1); scanf("%d%d",&v1,&v2); } }
void find_all_neighbors(Graph G,VertexType x,VertexType data[]) { int index=vex_is_exist(G,x); if(index==-1){return;} int count=0; ArcNode*pre=G.vertices[index].first; while(pre) { data[count++]=pre->adjVex; pre=pre->next; } }
|