All Pairs Shortest Path Using C programming
Given a directed, connected weighted graph G ( V , E ) , for each edge ⟨ u , v ⟩ ∈ E , a weight w ( u , v ) is associated with the edge. The all pairs of shortest paths problem (APSP) is to find a shortest path from u to v for every pair of vertices u and v in V . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 #include<conio.h> #include<stdio.h> int n,i,j,k,cost[ 10 ][ 10 ]; void apsp ( int [ 10 ][ 10 ]); int min ( int , int ); void main () { // here we accept the cost matrix: printf( "Enter the no of vertices: " ); scanf( "%d" ,&n); printf( "Enter the cost adjacency matrix: " ); for (i= 1 ;i<=n;i++) { for (j= 1 ;j<=n;j++) { scanf( "%d...
Comments
Post a Comment