competitive-programming-library

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

View the Project on GitHub yu-0811/competitive-programming-library

:warning: algorithm_library/python/graph/cycle_detect.py

Code

vis = [False]*(N+1)
fin = [False]*(N+1)
history = deque()

# 頂点 v の連結成分内の閉路を返す
def cycle_detect(v):
  sta = deque()
  sta.append((v,0))
  cycle_start = -1
  while sta and cycle_start == -1:
    v,prev = sta.pop()
    if prev == -1:
      history.pop()
      fin[v] = True
      continue
    if vis[v]: continue
    vis[v] = True
    history.append(v)
    for v2 in G[v]:
      if v2==prev: continue
      if fin[v2]: continue
      if vis[v2]: # 閉路検出
        cycle_start = v2
        break
      sta.append((v2,-1))
      sta.append((v2,v))
  
  cycle = list()
  if cycle_start == -1: return cycle
  while history:
    v = history.pop()
    cycle.append(v)
    if v == cycle_start: break
  return cycle
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/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.11.0/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page