A directed graph has n nodes and edges[i] = [u, v, w] (an edge from u to v of weight w; weights may be negative). Return an array whose entry v is the largest total weight of a path from src to v, with -Infinity for nodes that src cannot reach (and 0 for src itself). If the graph contains a cycle, return null.
- Process the nodes in topological order and relax each edge once: O(V + E)
- Parallel edges are possible
- The longest path on a general graph is a different, much harder problem; here the order does the work