Python3 solution based on standard BFS template
\nclass Solution:\n    def minTime(self, n: int, edges: List[List[int]], hasApple: List[bool]) -> int:\n        # intuition: Build a directed graph to keep trac
```\nclass Solution:\n    def minTime(self, n: int, edges: List[List[int]], hasApple: List[bool]) -> int:\n        # intuition: Build a directed graph to keep track of parent nodes. \n\t\t# Mark parent nodes of apple nodes as apples node by updating "hasApple". \n\t\t# Do BFS from given apple nodes. It takes 2 steps from one apple node (including later marked ones) to a child apple node. \n\t\t#Final time excludes the node 0.\n        \n        # build a directed graph since we need to do BFS level up \n        graph = collections.defaultdict(list)\n        for s, t in edges: \n            if t in graph.keys(): graph[s].append(t) #####\n            graph[t].append(s) # the parent of node t is node s #####\n        \n        # do BFS from child to parent, level up\n        visited = set()\n        queue = deque()\n        for i, node in enumerate(hasApple):\n            if node: queue.append(i)\n        while queue:\n            curr = queue.popleft()\n            visited.add(curr)\n            hasApple[curr] = True # mark as apple node\n            for p in graph[curr]:\n                if p not in visited:\n                    queue.append(p)\n        return sum(hasApple[1:]) * 2 # True = 1 and False = 0\n```
['Breadth-First Search']