# Depth-first search for finding connectedness in Digraph.
#
# Jesper Larsson, Malmö University, 2018–2020

from clo_decorators import clo_method

class DFS:
    def __init__(self, G, s):
        marked = [False] * G.V
        def dfs(G, v):
            marked[v] = True
            for w in G.adj(v):
                if (not marked[w]):
                    dfs(G, w)

        dfs(G, s)

        @clo_method(self, 'marked')
        def _(v):
            return marked[v] 
