summaryrefslogtreecommitdiff
path: root/37/CH8/EX8.6
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /37/CH8/EX8.6
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 '37/CH8/EX8.6')
-rwxr-xr-x37/CH8/EX8.6/s6.sci27
1 files changed, 27 insertions, 0 deletions
diff --git a/37/CH8/EX8.6/s6.sci b/37/CH8/EX8.6/s6.sci
new file mode 100755
index 000000000..72e5126c7
--- /dev/null
+++ b/37/CH8/EX8.6/s6.sci
@@ -0,0 +1,27 @@
+//Depth First Search Traversal
+funcprot(0)
+function[]=Dfs(adj,n);
+ i=1,j=1;
+ colour=[];
+ for i=1:n
+ for j=1:n
+ colour=[colour(:,:) 0];
+ end
+ end
+ disp("The DFS traversal is");
+dfs(adj,colour,1,n);
+endfunction
+function[]=dfs(adj,colour,r,n)
+ colour(r)=1;
+ disp(r," ");
+ for i=1:n
+ if(adj((r-1)*n+i)&(colour(i)==0))
+ dfs(adj,colour,i,n);
+ end
+ end
+ colour(r)=2;
+endfunction
+//Calling Routine:
+n=4;
+adj=[0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 0]
+Dfs(adj,n) \ No newline at end of file