#include #include #include "graph.h" int main (int argc, char *argv[]) { //make sure you aren't getting garbage in if((argc==1)||(argc-1)%3){ printf("please supply real input\n"); exit(1); } //add the first link manually vertex_t *head = NULL; head = add_vert(head, argv[1]); add_edge(head,argv[1],argv[2],atoi(argv[3])); int i; //add the other links for(i = 4; i < argc; i+=3){ add_edge(head,argv[i],argv[i+1],atoi(argv[i+2])); } vertex_t *vp =NULL; adj_vertex_t *adj_v =NULL; /* print out our adjacency list */ printf("Adjacency list:\n"); for (vp = head; vp != NULL; vp = vp->next) { printf(" %s: ", vp->name); for (adj_v = vp->adj_list; adj_v != NULL; adj_v = adj_v->next) { printf("%s(%d) ", adj_v->vertex->name, adj_v->edge_weight); } printf("\n"); } //call tour (which prints out a tour inside the function, then free the tour free_tour(tour(head)); //free the graph free_all(head); return 0; }