[Python] DFS and BFS solution
DFS solution:\npython\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        ans = 0\n    
DFS solution:\n```python\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        ans = 0\n        graph = collections.defaultdict(dict)\n        for u, v, t in edges:\n            graph[u][v] = t\n            graph[v][u] = t\n        \n        def dfs(curr, visited, score, cost):\n            if curr == 0:\n                nonlocal ans\n                ans = max(ans, score)\n            \n            for nxt, time in graph[curr].items():\n                if time <= cost:\n                    dfs(nxt, visited|set([nxt]), score+values[nxt]*(nxt not in visited), cost-time)\n        \n        dfs(0, set([0]), values[0], maxTime)\n        return ans\n```\n\nBFS solution\n```python\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        ans = 0\n        graph = collections.defaultdict(dict)\n        for u,v,t in edges:\n            graph[u][v] = t\n            graph[v][u] = t\n        \n        # node, cost, visited, score\n        q = collections.deque([(0, maxTime, set([0]), values[0])])\n        while q:\n            curr, cost, visited, score = q.popleft()\n            if curr == 0:\n                ans = max(ans, score)\n            for nxt, time in graph[curr].items():\n                if time > cost:\n                    continue\n                q.append((nxt, cost-time, visited|set([nxt]), score + values[nxt]*(nxt not in visited)))\n\n        return ans\n```
['Depth-First Search', 'Breadth-First Search', 'Python', 'Python3']