typedef struct arcn
{ int id; arcn *next; } arcn;
typedef struct vn
{ float price; arcn *next;} vn;
typedef struct
{ vn adjlist[100]; int vnum,arcnum;} G;
typedef struct EdgeNode{int adjvex;EdgeType weight;struct EdgeNode *next;}EdgeNode;
typedef struct VertexNode{VertexType data;struct EdgeNode *firstdege;}VertexNode,AdjList[MAXVEX];
typedef struct {AdjList adjList;int mumNodes;int numEdges;}GraphAdjList;
int vexs[4]={1,2,3,4};
int adj[4][4]={0,1,0,1,1,0,1,1,0,1,0,1,1,1,1,0}
void f(Graph *G)
{
G->numberEdges=10;
G->munbersNodes=4;
int i,j;
for(i=0;i<G->numberNodes;++i)
{
G->adjList[i].data=0;
G->adjList[i].firstedge=NULL;
}
EdgeNode *pe;
pe=(EdgeNode*)malloc(sizeof(EdgeNode));
for(i=0;i<4;i++)
{for(j=0;j<4;i++)
{
if(adj[i][j]!=0)
{ pe=(EdgeNode*)malloc(sizeof(EdgeNode));
pe->adjvex=j;pe->weight=adj[i][j];pe->next=G->adgList[i].firstedge;
G->adjList[i].firstedge =pe;
G->adjList[i].data++;
}
}
}
}