Problem 22-1 Classifying edges by BFS

Recall that the BFS(s) works as follows:

Q.enqueue(s)
while(!Q.isempty())
  u = Q.dequeue()
  foreach v in adj(u)
    if v is WHITE
      paint v to GRAY
      v.depth = u.depth +1
      Q.enqueue(v)
      edge(u,v) is a tree edge

  

a)

  1' Suppose for contradiction that there is a back edge (u,v) in the result produced by BFS(s).
    Notice that G is an undirected graph, thus (u,v) == (v,u). And that v is the descendent of u in the BFS tree.
    Thus, when BFS procedes to u, v is still WHITE. thus it will enqueue v and making (u,v) an tree edge. Contradiction.
    Similiarly, a forward edge would also become an tree edge, yielding a contradiction.
  2' Apparent from the BFS procedual.(which is the only case tree edges can be produced.)
  3' cross edge shall be those edge through siblings (the dequeue procedual of their common parents making them both to GRAY, making this edge a cross edge) or those edge between sibling and its direct descendent (v.p is sibling of u, and it lies in front of u in Q).


b)

  1' similiar to a1.
  2' similiar to a2.
  3' suppose for contradiction that there exists an edge (u,v) s.t. v.d > u.d+1. That is, δ(s, u) + 1 < δ(s, v). Which contradicts to Lemma22.1
  4' Do I really need to prove this? That's a back edge!

 

Problem 22-2 Articulation points, Bridges and Biconnected components.


a) Proof:

    Denote this root as r, and its first two child in G[π] (if any) as u, v.
    As G is undirected and connected, G[π] shall contain every vertex in G.
    Sufficiency:
      It suffices to prove that u and v shall be disconnected after r is removed from the graph.
      Suppose for contradiction that there exists a path p[u ~> v] in G even after r is removed.
      Without loss of generity, suppose that r.d+1 = u.d < v.d.
      Now, we prove that every vertex along p is white at the time of u.d
      coz if not, then there exists some x along p s.t. x.d < u.d. Without loss of generity, suppose that every vertice from u down along path p until x is white at the time of u.d.(If not, move x up along p until u->x, where the condition holds).
      As x couldn't be r, it must have been discovered before DFS enters G[π]. Thus, by the time of x.d, every vertice along the path along p up until u(then to r, then to even every vertex in G[π]) must be white. by the white pass theorem, every vertex in G[π] must have become descendent of x. Thus x becomes the root, which leads to a contradiction.
      By the white path theorem, v must have become a descendent of u, rather than a child of r.Which leads to a contradiction.
    Q.E.D.
    Necessity:
      Suppose for contradiction that...
      If r has no child, removing r will making G empty, where the contradiction rises trivally.
      If r has only one child, removing r will only loss one sufficient edge (r,u), other part of the graph should still be connected by the remaining part of G[π]. Thus lead us to a contradiction.
    Q.E.D.

b) Proof:

  Sufficiency:
    Let's remove v from G. As the tree rooted at s have no back edge to a proper ancestor of v, it suffices to prove that there exists no cross edge between any vertice v in tree rooted at s and u in any other part of G. This follows directly from Theorem 22.10
  Necessity:
    If not, every part of its descendent can connect through this back edge back to its ancesters, then to its siblings, making the remainder of the graph still connected, which yields to a contradiction.

C)

  using DFS to mark every edges, then compare those back edges's vertices' d. As this is a undirected connected Graph, E+1 < V < E , the whole procedual shall take O(E) time


d)

  using DFS to mark every edges, then mark every vertex as ariticulation points, then check every vertex(and their edges ) along G[pi] to see if root of G[pi] have less than one child, and to see if there are any back edges. If they do, mark every ancester from the deeper end of the back edge as non-articulation points, ( stop if it already encounters one).
  The whole procudual shall take O(E) time to finish.

e)

  apparently

f)

   Mark every edge as a bridge.
  Perform DFS to mark every edges.
  Once encountering a back edge(u,v), mark every tree edge along the path (v~>u) as a non tree edge.

/*Unfinished*/ 

 

Problem 22-3 Euler tour

Notice that:
  1' As G is a Strongly connected directed graph, |E| >= |V|. When |E| = |V|, G is a simple circle. Thus for each v in V, id(v) = od(v) = 1. The conclusion follows trivally under such circumstance. When |E| >= |V|, id(v) >= 1, od(v) >= 1 for each v in V.
  2' sum id(v) = sum od(v) = |E| for any directed Graph G.
  3' Euler tour is a single circle that can be decompromised into several simple circles with disjointed edges.

Necessity:

  From Notation3', we decompromise the Euler tour into a set of simple circles.
  For each simple circle in the set,
  for each vertex in V, id(v) = od(v) = either 0 (v is not in that circle) or 1 (v is in that circle)
  Adding this up, we have that id(v) = id(v) for each vertex in V

Sufficiency:

  For any v in V, we have that id(v) = od(v). Denote it as f(v). From notation 1', f(v) >= 1 for any v in V.
  We firstly prove that, for any r in V s.t. f(v) >= 1, we can construct a circle in G that contains r:

 

C.enqueue(r)
do
    v = C.last()
    choose an arbitrary u in adj(v)
      remove u from adj(v), thus remove (v,u) from E, id(u)--, od(v) --
      if od(v) == 0, remove v from V
          C.enqueue(u)
while (C.last() != C.first()

 

  

 

We shall prove that this procedual shall derive a single circle out of G without disturbing the property that G is still a Strongly connected directed graph.


Firstly we prove that the loop inviariant of line 3-7 is that, before entering line3,

    1' Apart from the first loop (where C.last() == C.first() == r), id(C.last()) == od(C.last()) - 1 >= 0, id(C.first()) == od(C.first()) + 1
    2' Apart from the first loop, for any vetex u in V other than C.first() and C.last(), id(u) == od(u) >= 1.
    3' For any vertex u being removed from V, id(u) == od(u) == 0, if u != r
    4' The G(V,E) being left behind shall be still strongly connected if we add r into V and add an edge (r,C.last())


Initialization

Initialization is the first loop. Before entering line 3 for the first time, every vertex u in V saitisfies id(u) == od(u) >= 1 from notation1'.
  the loop will be execuated for another time iff u != r at line 4.
    After line 5, id(u) == od(u) -1, od(C.first()) == id(C.first()) -1.
    After line 7, u becomes the new C.last(), thus property1' and 2' both holds. property 3 holds trivally. Thus property 4 holds.
  However, if u do == r,
    then id(r) = id(r) -1, od(r) = od(r) -1, we've successfully produced a single circle without disturbing the property of G.


Within the loop 

  At line3, id(v) == od(v) -1, u couldn't be C.first().
  if u == v, then id(v) == od(v) - 1 >= 1, v couldn't have been removed at line 6. after line 5 and 7, property 1, 2 and 3 still holds.
  if u != v, then id(u) == od(u) >= 1, after line 5 and 7, property 1 and 2 still holds. if v was removed at line 6, then before line 5 od(v) == 1, from property 1', id(v) == 0, thus property3' still holds. Thus property 4 holds.


Termination

Upon termination loop, u == C.first() == r. [r is reachable based on property 4] Thus we've successfully produced a loop.
  Before line 5, id(r) == od(r) + 1, id(v) == od(v) - 1
  After line 5, id(r) == od(r), id(v) == od(v).
  If od(v) == 0, v shall be removed from V.
  If od(r) == 0, r shall be already removed.
  else, v and r shall be still in V.
  Thus every vertex remains in G after the procedual stiil satisfies id(v) == od(v) >= 1, and we've managed to produce a circle.


  Repeat this procedual until G becomes empty. We can then produce a single circle, namely Euler path, based on the circles we've produced.


Q.E.D.

 

Problem 22-4 Reachability


The procedual works as follows:
MinR(G)

Build G'
run DFS on G' in the order of L(u).
for any DFS tree T rooted at r, for any vertex v in T, min(v) = L(r).

The whole procedual takes O(V+E)-time.


Lemma P1: There is a path u~>v in G', iff there is a path as the exact reverse , v~>u in G.
Corollary P2: for any v in R(u), v~>u exists in G': follows directly from LemmaP1.

Theorem P3: Correctness of MinR(G):
 Proof:

  prove by induction on DFS trees already been produced at line2.
  Base: if no tree has been produced, the conclusion follows trivally.
  Inductive step: Suppose that every tree produced so far satisfies that if tree T is rooted at r, then for every v in T, min(v) = L(r).
    Let s denote the root of the next tree being produced.
    Then L(s) = min {v: v.color == WHITE by the time of s.d}
    For any u s.t. R(u) contains s, we have that min(u) <= L(s)
      if min(u) = L(v) < L(s), by corollary P2, v~>u exists in G', and shall be a white-path by the time of v.d. Thus, v.d < u.d < u.f < v.f < s.d
      Thus u shall be black by the time DFS() discovers s.
      if min(u) = L(s), L(u) >= L(s), and for every vertex w along the path s~>u in E', w shall be WHITE.
        if not, as s is the root, w must be BLACK. without loss of generity, let w denote the first BLACK vertex along that path.
        Then w.f < s.d, then min(w) = L(v) < L(s). as w~>u exists in E', u~>w shall exist in E. thus u~>w~>v exist in E, thus yields a contradiction: min(u) <= L(v) < L(s).
      Thus by the white-path theorem, u shall become a proper descendent of s.
Q.E.D.