Page 278, Exercise 9

Data Structure & Call
typedef struct Node *NodePointer;
	struct  Node
	 {
	       int  Vertex;
	       struct Node *Link;
	 };
typedef NodePointer Lists[MAX_SIZE];
 
 Lists  AdjList;
 CreateList(AdjList);


Function Definition
void CreateList(Lists AdjList)
{/* create the adjacency list */
   int i, Vertex1, Vertex2;
   NodePointer temp;
  /* Initialize all of the pointers to NULL, including the
     0 position which is never used.  Failure to do so
     causes the system to blow  up !!! */
  for (i=0; i= 0)
  {
    /* place vertex 1 in vertex 2's adjacency list */
     temp = (NodePointer)malloc(sizeof(struct Node ));
     temp->Vertex = Vertex1;
     temp->Link = AdjList[Vertex2];
     AdjList[Vertex2] = temp;
     /* place vertex 2  in vertex 1's adjacency list */
     temp = (NodePointer) malloc(sizeof (struct Node));
     temp-> Vertex = Vertex2;
     temp->Link = AdjList[Vertex1];
     AdjList[Vertex1]  = temp;
     printf("Enter a pair of vertices, 0 0 to quit: ");
     scanf("%d%d",&Vertex1,&Vertex2);
   }
}