<commit_before>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


def _dfs_stack_explore():
    pass

def dfs_stack():
    """Depth first search by iteration algorithm using stack."""
    pass


def main():
	# Connected graph by adjacency dictionary.
    graph_adj_d = {
        'A': ['B', 'D'],
        'B': ['C', 'D'],
        'C': [],
        'D': ['E'],
        'E': ['B', 'F'],
        'F': ['C'],
    }
    print('Graph:\n{}'.format(graph_adj_d))


if __name__ == '__main__':
	main()<commit_msg>Complete alg_depth_first_search_stack<commit_after>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


def _previsit(v_visit, previsited_d, clock):
    clock += 1
    previsited_d[v_visit] = clock
    return previsited_d, clock


def _dfs_stack_explore(v, graph_adj_d, visited_d,
                       previsited_d, clock):
    visit_stack = []
    visit_stack.append(v)
    while visit_stack:
        v_visit = visit_stack.pop()
        visited_d[v_visit] = True
        previsited_d, clock = _previsit(v_visit, previsited_d, clock)
        for v_neighbor in graph_adj_d[v_visit]:
            if not visited_d[v_neighbor]:
                visit_stack.append(v_neighbor)
    return previsited_d


def dfs_stack(graph_adj_d):
    """Depth first search by iteration algorithm using stack."""
    visited_d = {v: False for v in graph_adj_d.keys()}
    previsited_d = {}
    clock = 0
    for v in graph_adj_d.keys():
        if not visited_d[v]:
            previsited_d = _dfs_stack_explore(
                v, graph_adj_d, visited_d, 
                previsited_d, clock)
    return previsited_d


def main():
	# Connected graph by adjacency dictionary.
    graph_adj_d = {
        'A': ['B', 'D'],
        'B': ['C', 'D'],
        'C': [],
        'D': ['E'],
        'E': ['B', 'F'],
        'F': ['C'],
    }
    print('Graph:\n{}'.format(graph_adj_d))

    previsit_d = dfs_stack(graph_adj_d)
    print('previsit_d: {}'.format(previsit_d))


if __name__ == '__main__':
	main()
{'fraction_non_alphanumeric': 0.13142857142857142, 'fraction_numerical': 0.0009523809523809524, 'mean_word_length': 2.7450980392156863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1531924', 'n_tokens_mistral': 739, 'n_tokens_neox': 723, 'n_words': 172}