def dfs(self):
    """
    Computes the initial source vertices for each connected component
    and the parents for each vertex as determined through depth-first-search
    :return: initial source vertices for each connected component, parents for each vertex
    :rtype: set, dict
    """
    parents = {}
    components = set()
    to_visit = []

    for vertex in self.get_vertex():
        if vertex not in parents:
            components.add(vertex)
        else:
            continue

        to_visit.append(vertex)

        while to_visit:
            v = to_visit.pop()

            for neighbor in self.get_neighbor(v):
                if neighbor not in parents:
                    parents[neighbor] = v
                    to_visit.append(neighbor)

    return components, parents