Find the most expensive path from s to t using DFS
问题 In a given graph G=(V,E) each edge has a cost c(e) . We have a starting node s and a target node t. How can we find the most expensive path from s to t using following DFS algorithm? DFS(G,s): foreach v in V do color[v] <- white; parent[v] <- nil DFS-Visit(s) DFS-Visit(u) color[u] <- grey foreach v in Adj[u] do if color[v] = white then parent[v] = u; DFS-Visit(v) color[u] <- black What I have tried: So first we create an array to maintain the cost to each node: DFS(G,s,t): foreach v in V do