int main() { Graph g; int n , short_dist; n = create(&g); display(&g, n); short_dist = dijstras(&g, n); printf("\n Shortest Distance : %d ", short_dist); return 0; }
//driver program int main(){ int i,j; for(i=1; i<=NUM_NODE; i++){ graph[i] = create_node_1(i,0); } // creating graph with weighted edges. add_edge_2(1,2,4); add_edge_2(1,3,8); add_edge_2(2,3,9); add_edge_2(2,4,9); add_edge_2(3,4,2); add_edge_2(2,5,10); add_edge_2(3,6,1); add_edge_2(4,5,7); add_edge_2(4,6,9); add_edge_2(5,6,6); add_edge_2(6,7,2); add_edge_2(7,5,5); // Adjancancy matrix based representation for(i=1; i<=NUM_NODE; i++){ printf("Nodes adjacent to %d : ", i); Node * current = graph[i]; while(current){ printf("%d ", current->value); current = current->next; } printf("\n"); } dijstras(graph, 1, 6); return 0; }