From e77cc376aaff8ca481fdace6d5795c5b5feb0e87 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 20 Feb 2012 14:45:20 +0100 Subject: Added pc descriptor calc service --- java/docs/algo/DepthFirstSearch.html | 137 +++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 java/docs/algo/DepthFirstSearch.html (limited to 'java/docs/algo/DepthFirstSearch.html') diff --git a/java/docs/algo/DepthFirstSearch.html b/java/docs/algo/DepthFirstSearch.html new file mode 100644 index 0000000..a4afe64 --- /dev/null +++ b/java/docs/algo/DepthFirstSearch.html @@ -0,0 +1,137 @@ +

Depth First Search (DFS)

The DFS method performs a depth--first search [clr98] of a graph. +A depth--first search visits vertices that are further to the +source before visiting vertices that are closer away. In this +context `distance' is defined as the number of edges in the +shortest path from the source vertex. +

Figure 1. Pseudocode for the DFS algorithm

DFS(G)
+  {
+    For each v in V,
+    {
+      color[v]=white;
+      pred[u]=NULL
+    }
+
+    time=0;
+    For each u in V
+      If (color[u]=white) DFSVISIT(u)
+  }
+
+
+  DFSVISIT(u)
+  {
+    color[u]=gray;
+    d[u] = ++time;
+
+    For each v in Adj(u)  do
+      If (color[v] = white)
+      {
+        pred[v] = u;
+        DFSVISIT(v);
+      }
+
+    color[u] = black; f[u]=++time;
+  }
+The time complexity is [clr98].


  Next
  Bibliography
\ No newline at end of file -- cgit v1.2.3