2 Graph Connectivity
2.1 Connected Graph
Figure 1: Unconnected Graph Figure 2: Connected Graph
2.2 Sub-Graph
Let G′ = (V, E) is a sub-graph of G = (V, E) if and only if V ′ ⊆ V and E ′ ⊆ E and ∀ v, u
∈ V ′ , [v, u] ∈ E ⇔ [v, u] ∈ E ′ .
Figure 3: Graph G
Example we have sub graph below:
Figure 4: Graph G′0 Figure 5: Graph G′1
4
2.3 Connected Components
Algorithm 1 Connected Component
* Input : Graph G = (V, E)
* Output: List of components connected
1. J ←− 1 :
2. While not all nodes have been classified Do
[Link] an unclassified starting node:
ii.S ←− starting node:
[Link] S in component number J
iv. While S is not finished Do
* While possible Do
S ←− an unclassified neighbor of S
Classify S in J.
* End While
* Mark S as finished
* S ←− node from which S was classified if S is not the starting vertex
v. End While
vi. J ←− J + 1
3. End While
Figure 6: Graph G
We have G as figure above which has 2 components connected.
5
2.4 Strongly Connected and Strongly Connected Components
2.4.1 Strongly Connected
Note: A directed graph is strongly connected if, for every pair of vertices (u, v), there is a
path from u to v and another path from v to u.
Figure 7: Connected but not
strongly connected Figure 8: strongly connected
2.4.2 Strongly Connected Components
Algorithm 2 Strongly Connected Components
* Input : Graph G = (V, E)
* Output: List of strongly components connected
1. X ←− V :
2. While X is not empty Do
i. C ←− ∅ : (C is components)
ii. Mark a vertex x from X with + and −:
iii. While possible Do
* Mark with + any successor (not already marked with +) of a vertex already
marked with +;
* Mark with − any predecessor (not already marked with −) of a vertex already
marked with −;
iv. End While
v. Write C, the set of vertices marked with + and −;
vi. The sub-graph of G with nodes from C is an strongly connected component of
G.
vii. X ←− X − C
3. End While
6
Figure 9: strongly connected component
2.5 Eulerian and Hamiltonian path
• Hamilton Path : is a path that contains each vertex of a graph exactly once.
• Hamilton Theorem: If G be a a simple undirect graph with n vertices and d(v) +
d(w) ≥ n − 1 whenever v and w are two vertices that not adjacent, then G has a
Hamilton path.
• Euler path: is a path in a graph that visits every edge exactly once.
• Euler Theorem: A connected graph G is Eulerian if and only if number of node (0
or 2 node ) with the odd degree.
Figure 10: bridge G - Not bridge G
7
Algorithm 3 Euler walk
* Input : Graph G = (V, E) has 2 nodes with odd degree
* Output: Euler path G′
1. G′ ←− G :
2. Start from a vertex of odd degree.
3. While G′ is not empty Do
i. Traverse an edge e that is not a bridge in G′ except if we are on a vertex of degree
1 in G′
ii. G′ ←− G′ \ {e}
4. End While
2.6 Adjacency matrix
2.7 Transitive Closure
Let G = (V, E) be graph. τ (G) = (V, τ (E)) was called transitive closure of G if for all
(x, y) ∈ V .
(x, y) ∈ τ (E) ⇐⇒ ∃ path x → y in G.
Figure 11: GraphG - Transitive Closure of G
8
Algorithm 4 Roy Wharshall algorithm
* Input : A directed graph G = (V, E)
* Output: The transitive closure of G
For w ∈ U Do
For v ∈ U Do
For u ∈ V Do
If (u, w) ∈ E and (v, w) ∈ E then Input (u, v) ∈ E
2.8 Partial Graph
Let graph G = (V, E). we have G′ = (V ′ , E ′ ) is a partial graph of G if E ′ is include in E.
2.9 τ -equivalent
• G and G′ was called τ -equivalent if τ (G) = τ (G′ ).
• Graph G′ was called τ - minimal τ -equivalent with G if G′ is a partial graph of G and τ -
equivalent to G , if we remove an edge of G′ we obtain a graph that is not τ -equivalent
to G.
• Graph G′ was called τ - minimum τ -equivalent to G if it’s τ - minimal τ -equivalent with
the number minimum of edges.