京都大学 情報学研究科 数理工学専攻 2021年8月実施 アルゴリズム基礎
Author
祭音Myyura
Description
日本語版
(i)
(ii)
(iii)
English Version
Let
(i) Assume that
(ii) Give an
(iii) Construct an example of a directed graph
Kai
(i)
We use BFS to compute shortest paths in an unweighted graph.
BFS(s, G=(V, E)):
for each v in V set dist(s, v; G) = |V|
for each v in V set visited(v) = 0
for each v in V set pred(v) = -1
dist(s) = 0
visited(s) = 1
set Q to be the empty queue
Q.enqueue(s)
while Q is not empty do:
u = Q.dequeue()
for each neighbor v of u do:
if visited(v) = 0 then:
visited(v) = 1
Q.enqueue(v)
dist(s, v; G) = dist(s, u; G) + 1
pred(v) = u
The time complexity of BFS is
(ii)
The idea is to find "bridges" in the graph that consists of all the edges of shortest paths from
Let
- use BFS to compute
- let
denote the reversed graph of (i.e. the same vertex set but all of the edges reversed), use BFS to compute
Obviously, it takes
Then, we can use Tarjan' algorithm to find bridges
GetArticulationPoints(i, d)
visited[i] := true
depth[i] := d
low[i] := d
childCount := 0
isArticulation := false
for each ni in adj[i] do
if not visited[ni] then
parent[ni] := i
GetArticulationPoints(ni, d + 1)
childCount := childCount + 1
if low[ni] ≥ depth[i] then
isArticulation := true
low[i] := Min (low[i], low[ni])
else if ni ≠ parent[i] then
low[i] := Min (low[i], depth[ni])
if (parent[i] ≠ null and isArticulation) or (parent[i] = null and childCount > 1) then
Output i as articulation point
The time complexity of Tarjan' algorithm is also
If there exists a articulation point