/* Program for addition and deletion of nodes and edges in a - TopicsExpress



          

/* Program for addition and deletion of nodes and edges in a graph using adjacency matrix */ #include #define max 20 int adj[max][max]; int n; main() { int choice; int node,origin,destin; create_graph(); while(1) { printf("1.Insert a node "); printf("2.Insert an edge "); printf("3.Delete a node "); printf("4.Delete an edge "); printf("5.Dispaly "); printf("6.Exit "); printf("Enter your choice : "); scanf("%d",&choice); switch(choice) { case 1: insert_node(); break; case 2: printf("Enter an edge to be inserted : "); fflush(stdin); scanf("%d %d",&origin,&destin); insert_edge(origin,destin); break; case 3: printf("Enter a node to be deleted : "); fflush(stdin); scanf("%d",&node); delete_node(node); break; case 4: printf("Enter an edge to be deleted : "); fflush(stdin); scanf("%d %d",&origin,&destin); del_edge(origin,destin); break; case 5: display(); break; case 6: exit(); default: printf("Wrong choice "); break; }/*End of switch*/ }/*End of while*/ }/*End of main()*/ create_graph() { int i,max_edges,origin,destin; printf("Enter number of nodes : "); scanf("%d",&n); max_edges=n*(n-1); /* Taking directed graph */ for(i=1;i n || destin > n || origin
Posted on: Thu, 27 Jun 2013 02:53:54 +0000

Trending Topics



Recently Viewed Topics




© 2015