Lab 12 Notes


Graphs Theory Recap


Today Summary


Today Work


Organization issues: last 30 mins

- still lot to mark
- I plan to do it in the next 7 days
- We can schedule anothor meeting if you are interested to comment 
and discuss marks if there is enough interested
- Also if you have other questions
- I will send you an email

Recap: DFS algorithm for Trees

Alg

DFS (Tree T)
    Queue q
    q.enqueue(T.head)
    while ! q.empty
        node = q.dequeue()
        print (node)
        for each child of node 
            q.engueue(child)
    end while

Observations:

Alg

DFS (Graph G)
    Queue q
    ColorAllWhite(G)                    // * TODO

    // start with start node    
    s := Graph.startNode()
    s.color := gray                     // *
    s.dist  := 0                        // *
    s.pred  := null                     // *
    q.enqueue(s)

    while ! q.empty()
        node = q.dequeue()
        for each adj node v of node
            if v.color = white          // first time we see it
                v.color := gray         // *
                v.dist  := node.dist+1  // *
                v.pred  := node         // *
                q.enqueue (v)
        node.color := black             // *

    end while

Running time: ?
\Theta( |V| + |E| )