Neterukun's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Neterukun1993/Library

:heavy_check_mark: 二重辺連結成分分解
(Graph/Decomposition/TwoEdgeConnectedComponents.py)

概要

無向グラフを二重辺連結成分分解するアルゴリズム。

使い方

TwoEdgeConnectedComponents(n: int)
頂点数 n の辺のないグラフを構築する。計算量 $O(V)$

Depends on

Verified with

Code

from Graph.misc.LowLink import LowLink


class TwoEdgeConnectedComponents(LowLink):
    def build(self):
        super().build()
        self.labels = [-1] * self.n
        self.lb_cnt = 0
        for v in range(self.n):
            if self.labels[v] != -1:
                continue
            self.labels[v] = self.lb_cnt
            stack = [v]
            while stack:
                v = stack.pop()
                for nxt_v in self.graph[v]:
                    if self.ord[v] < self.low[nxt_v] or self.ord[nxt_v] < self.low[v]:
                        continue
                    if self.labels[nxt_v] != -1:
                        continue
                    self.labels[nxt_v] = self.lb_cnt
                    stack.append(nxt_v)
            self.lb_cnt += 1

    def groups(self):
        res = [[] for _ in range(self.lb_cnt)]
        for v, lb in enumerate(self.labels):
            res[lb].append(v)
        return res
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page