Since last 2 days,i\'m trying to find some logic for calculating longest path in graph.I know i can find it easily for DAGs and in general it is polynomial time algorithm.Formal
Invert the weights of the paths and run a shortest path algorithm. The lowest number you get (most negative) is the longest path.