summaryrefslogtreecommitdiff
path: root/1034/CH6/EX6.3
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1034/CH6/EX6.3
downloadScilab-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.3')
-rwxr-xr-x1034/CH6/EX6.3/6s3.sce34
1 files changed, 34 insertions, 0 deletions
diff --git a/1034/CH6/EX6.3/6s3.sce b/1034/CH6/EX6.3/6s3.sce
new file mode 100755
index 000000000..15cd9748b
--- /dev/null
+++ b/1034/CH6/EX6.3/6s3.sce
@@ -0,0 +1,34 @@
+clear;
+clc;
+disp("Example 6.3");
+//Warshall's Algorithm
+clc;
+clear;
+funcprot(0)
+function[path]=transclose(adj,n)
+ for i=1:n
+ for j=1:n
+ path((i-1)*n+j)=adj((i-1)*n+j);
+ end
+ end
+ for k=1:n
+ for i=1:n
+ if(path((i-1)*n+k)==1)
+ for j=1:n
+ path((i-1)*n+j)=path((i-1)*n+j)|path((k-1)*n+j);
+ end
+ end
+ end
+ end
+ printf("Transitive closure for the given graph is:\n");
+ for i=1:n
+ printf("For vertex %d \n",i);
+ for j=1:n
+ printf("%d %d is %d\n",i,j,path((i-1)*n+j));
+ end
+ end
+endfunction
+//Calling Routine:
+n=3;
+adj=[0 1 0 0 0 1 0 0 0]
+path=transclose(adj,n) \ No newline at end of file