So let's say I have an acyclic, directed graph G
with nodes a0, a1, a2, b0, b1, b2, c0, c1, c2
and I know both the outgoing distance for each node to any of it's neighbors. What algorithm can I use to find the longest path between any two nodes that is less than a given length?
EDIT: I have looked at the Wikipedia page for the Longest path problem but I don't know whether to use the algorithm outlined in the 'Acyclic graphs and critical paths' section or the one in the 'Parameterized complexity' section. I'd have problems with either case. In the former, the algorithm requires you to have the incoming distance (I have the outgoing distance) and to be honest, the description in the latter goes over my head as far as implementation.
EDIT2: My completed graph is as follows
graph = {
"a0": set(["a1", "b0])
"a1": set(["a2", "b1"])
"a2": set(["b2"])
"b0": set(["b1", "c0"])
"b1": set(["b2", "c1"])
"b2": set(["c2"])
"c0": set(["c1"])
"c1": set(["c2"])
"c2": set([])
}
I also have the outgoing distance in a separate dictionary e.g.
edge_distance = {
"a0": 0
"a1": 4
"a2": 12
"b0": 2
"b1": 1
"b2": 4
"c0": 7
"c1": 2
"c2": 1
}
Technically the only node for which I have the incoming distance is c2
The path I want to find is a0 to c2
EDIT3: My graph, toposorted:
c2 b2 c1 a2 b1 c0 a1 b0 a0