I want to obtain longest path in a given Java code. This code might be present in form of a graph. Are there any opensource tools/ APIs that obtain this info ?
A:
To find the longest path you could consider every possible path and take the longest. Note: if you have a loop, this will be infinite.
BTW: Usually people try to find the shortest path.
Peter Lawrey
2009-06-02 06:26:24
+1
A:
As in, the longest execution path?
This does not seem easily doable. You could certainly "decode" Java bytecode in to "Java Assembly" (What's the proper name for that?), and create a graph based on branches in the code.
The problem is your graph would almost certainly have cycles, and your longest path is going to be infinite unless you start simulating execution.
Nick
2009-06-02 06:27:31
+2
A:
http://en.wikipedia.org/wiki/Bellman-Ford%5Falgorithm
just put weights as negative; and don't allow any cycles with sum of all vertexes in cycles to be negative (that would indicate infinitive loop)
bbaja42
2009-12-07 01:29:24