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 /1034/CH6/EX6.7 | |
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 '1034/CH6/EX6.7')
-rwxr-xr-x | 1034/CH6/EX6.7/6s7.sce | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/1034/CH6/EX6.7/6s7.sce b/1034/CH6/EX6.7/6s7.sce new file mode 100755 index 000000000..366f70da1 --- /dev/null +++ b/1034/CH6/EX6.7/6s7.sce @@ -0,0 +1,23 @@ +clear;
+clc;
+disp("Example 6.7");
+//Finding The Number Of Paths From One Vertex To Another Of A Given Length
+
+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
+ printf("Number of paths from vertex %d to %d of length %d are %d",i,j,k,b);
+ return b;
+endfunction
+//Calling Routine:
+n=3;
+adj=[0 1 1 0 0 1 0 0 0]
+b=path(1,n,adj,1,3)
\ No newline at end of file |