0

As the title says I have to find longest path in directed graph where each node has at most two incoming edges and two outgoing edges. I don't know if that fact helps anything.. The graph will have at most 10000 nodes. And I need to find the longest path from node 0 to node 'Exit' which will be 10001.

I tried to code dijkstra but it didn't work.

Thanks in advance.

someone12321
  • 755
  • 5
  • 24

1 Answers1

0

You could preprocess your graph and set edge weights to very high values for edges that are connected to nodes that break your rules and then use a modified version of dijkstra that returns longest path.

Paul Jackson
  • 2,077
  • 2
  • 19
  • 29