BFS
\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        graph = defaultdict(list)\n       
```\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        graph = defaultdict(list)\n        \n        for u,v,time in edges:\n            graph[u].append([v,time])\n            graph[v].append([u,time])\n            \n        seen = set()\n        seen.add(0)\n        queue = deque([(0,0,seen)])\n        answer = values[0]\n        memo = {}\n        while queue:\n            time, node, seen = queue.popleft()\n            currPoints = sum(values[i] for i in seen)\n            if node in memo:\n                prevTime, prevPoints = memo[node]\n                if prevTime <= time and prevPoints > currPoints:\n                    continue\n            memo[node] = (time, currPoints)\n            \n            if time > maxTime:\n                continue\n            if node == 0:\n                answer = max(answer, currPoints)\n                \n            for nei,val in graph[node]:\n                queue.append((time+val,nei,seen | {nei}))\n        \n        return answer\n```
['Breadth-First Search']