
def DFS(G,node):
    nodes = G.getnodes()
    visited = {}
    for n in nodes:
        visited[n] = False #trying to avoid the need to id nodes from 1..n
    DFS_util(G,node,visited)
    return list(visited.values()).count(True) - 1

def DFS_util(G,curr,visited):

    con = G.getconnected(curr)
    visited[curr] = True
    for n in con:
        if not visited[n]:
            DFS_util(G,n,visited)


a1ef4071f686d88b39581f6997ae8378760a6fa7
<mask token>

<mask token>


def DFS_util(G, curr, visited):
    con = G.getconnected(curr)
    visited[curr] = True
    for n in con:
        if not visited[n]:
            DFS_util(G, n, visited)

def DFS(G, node):
    nodes = G.getnodes()
    visited = {}
    for n in nodes:
        visited[n] = False
    DFS_util(G, node, visited)
    return list(visited.values()).count(True) - 1


def DFS_util(G, curr, visited):
    con = G.getconnected(curr)
    visited[curr] = True
    for n in con:
        if not visited[n]:
            DFS_util(G, n, visited)


def DFS(G,node):
    nodes = G.getnodes()
    visited = {}
    for n in nodes:
        visited[n] = False #trying to avoid the need to id nodes from 1..n
    DFS_util(G,node,visited)
    return list(visited.values()).count(True) - 1

def DFS_util(G,curr,visited):

    con = G.getconnected(curr)
    visited[curr] = True
    for n in con:
        if not visited[n]:
            DFS_util(G,n,visited)

