Consider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis, a failure of a single node, $3$, in the network on the left would prevent some of the still available nodes from communicating with each other. Nodes $1$ and $2$ could still communicate with each other as could nodes $4$ and $5$, but communication between any other pairs of nodes would no longer be possible.
Node $3$ is therefore a Single Point of Failure (SPF) for this network. Strictly, an SPF will be defined as any node that, if unavailable, would prevent at least one pair of available nodes from being able to communicate on what was previously a fully connected network. Note that the network on the right has no such node; there is no SPF in the network. At least two machines must fail before there are any pairs of available nodes which cannot communicate.
链接
题解
构建一棵 $dfs$ 树,序列 $dfn[i]$ 为深度优先数,表示 $dfs$ 时访问 $i$ 节点的序号,$low[i]$ 表示从 $i$ 节点出发能访问到的最小的深度优先数。
当且仅当节点 $u$ 满足如下两个条件之一时,$u$ 为割点:
- $u$ 为 $dfs$ 树的根,且 $u$ 至少有两个子节点。
- $u$ 不是 $dfs$ 树的根,至少存在一个节点 $v$ 是 $u$ 的子节点,且 $low[v] >= dfn[u]$。
若 $u$ 为割点,记 $subnets[u]$ 为 $u$ 的子节点数,则去掉 $u$ 后,图被分成 $subnets[u] + 1$ 个部分(每个子节点的部分和 $u$ 的祖先的部分),若 $u$ 为 $dfs$ 树的根,则分成 $subnets[u]$ 个部分(根节点没有祖先)。
代码
1 |
|