diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /37/CH8/EX8.3/s3.sci | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '37/CH8/EX8.3/s3.sci')
-rwxr-xr-x | 37/CH8/EX8.3/s3.sci | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/37/CH8/EX8.3/s3.sci b/37/CH8/EX8.3/s3.sci new file mode 100755 index 000000000..08546273b --- /dev/null +++ b/37/CH8/EX8.3/s3.sci @@ -0,0 +1,27 @@ +//Finding The Number Of Simple Paths From One Point To Another In A Given Graph
+funcprot(0)
+function[]=sim_path(n,adj,i,j);
+ l=0;
+ m=1;
+ for m=1:n
+ l=l+path(m,n,adj,i,j);
+ end
+ printf("There are %d simple paths from %d to %d in the given graph\n",l,i,j);
+endfunction
+function[b]=path(k,n,adj,i,j)
+ b=0;
+ if(k==1)
+ b=adj((i-1)*n+j);
+ else
+ for c=1:n
+ if(adj((i-1)*n+c)==1)
+ b=b+path(k-1,n,adj,c,j);
+ end
+ end
+ end
+ return b;
+endfunction
+n=3;
+adj=[0 1 1 0 0 1 0 0 0];
+b=sim_path(n,adj,1,3)
+
|