Even length path algorithm
问题 I was asked for my homework to write an efficient algorithm that finds all the vertices in a directed graph which have even length of path to them from the given vertex. This is what I thought of: (It's very similar to "Visit" algorithm of DFS) Visit(vertex u) color[u]<-gray for each v E adj[u] for each w E adj[v] if color[w] = white then print w Visit(w) I think it works but I'm having hard time calculating it's efficiency, especially when the graph is with cycles. Could you help me? 回答1: If