MHB Analyzing Depth-first Search Edge Types

  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Edge Search
evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

I want to apply the Depth-first search algorithm at the following graph.
We consider that at the iteration of the algorithm, we look at the nodes alphabetically. Also the nodes are registered alphabetically in each list. I want to calculate the "discovery" time and the "finish" time for each node and also the kind of each edge.

View attachment 3654
Code:
Depthfirstsearch(G)
   for each v ∈ V
        color[v]=white
        p[v]=NIL
   time=0
   for each v ∈ V
       if color[v]=white then
          Visit(v)

Code:
Visit(u)
  color[u]=gray
  time=time+1
  d[u]=time
  for each v ∈ Adj[u]
       if color[v]=white then
          p[v]=u
          Visit(v)
  color[u]=black
  time=time+1
  f[u]=time

I found these "discovery" and "finish" times:

View attachment 3655

Have I calculated them right? (Thinking)

Also, in order to find the kind of the edges I wanted to use this:

$$\begin{bmatrix}
\text{ tree edges: } x \to y & [d[y],f[y]] \subset [d[x],f[x]] \\ \\
\text{forward edges: } x \to y & [d[x],f[x]] \subset [d[y],f[y]] \\ \\
\text{back edges: } x \to y & [d[y],f[y]] \subset [d[x],f[x]] \\ \\
\text{Cross edges: } x \to y & [d[x],f[x]] \cap [d[y],f[y]]=\varnothing
\end{bmatrix}$$

But, when we have for example the case $[d[y],f[y]] \subset [d[x],f[x]]$ how can we know if it is a tree edge or a back edge? (Thinking)
 
Physics news on Phys.org
I think that I have done some mistakes.. (Lipssealed)
I think that it should be like that:

View attachment 3669But how can we find the type of the edges? :confused:
 

Attachments

  • discfin.png
    discfin.png
    7.2 KB · Views: 100
This graph:

View attachment 3678shows the parent of each node.
When there is a red edge does this mean that we have a tree edge? If so, could you explain me why? (Thinking)

Aren't $jh,ia$ forward edges and $ag$ a back edge? (Thinking)
 

Attachments

  • DNdZr.png
    DNdZr.png
    6.3 KB · Views: 96
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Back
Top