python super easy to understand dfs
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        \n        \n        graph = collections.defaultdict(set)\n        time = {}\n        for a, b, t in edges:\n            time[(a,b)] = t\n            time[(b,a)] = t\n            graph[a].add(b)\n            graph[b].add(a)\n        ans  = 0\n        def dfs(root, t, visit, s):\n            if t > maxTime:\n                return\n            if root == 0:\n                nonlocal ans\n                ans = max(ans, s)\n    \n            visit.add(root)\n            for v in graph[root]:\n                if v not in visit:\n                    dfs(v, t+time[(root,v)], set(visit), s+values[v])\n                else:\n                    dfs(v,t+time[(root,v)], set(visit), s)\n        \n        \n        dfs(0,  0, set(), values[0])\n        return ans\n\n\n\n\n```
['Depth-First Search', 'Python3']