Questions tagged [longest-path]

106 questions
2
votes
1 answer

Finding the longest path in the Sling Blade Runner puzzle

I've been trying to solve an archived ITA Software puzzle known as Sling Blade Runner for a few days now. The gist of the puzzle is as follows: "How long a chain of overlapping movie titles, like Sling Blade Runner, can you find?" Use the…
Christopher Perry
  • 38,891
  • 43
  • 145
  • 187
2
votes
1 answer

Path of length up to k with max value

I currently work on a problem where I want to try to find an algorithm which does the following: Given a square grid graph G and start node S and an end node E, where E and S in G, find a path P from S to E with maximum value and |P| <= k. If it…
jcklie
  • 4,054
  • 3
  • 24
  • 42
2
votes
1 answer

JGraphT: Stack overflow error with Liao Wong longest path algorithm?

I'm trying to implement a longest path algorithm in Java with jGraphT, but i get an java.lang.StackOverflowError when i compile. The error message point to the line where i copy the graph and to the line where the method calls itself inside the…
Whiteface
  • 21
  • 2
2
votes
2 answers

Longest path on a grid, without revisiting grid cells

I am looking for an algorithm to fidn the longest path between two points on a grid, with the added restriction that you cannot revisit a cell on the grid. (Also, you can only move up, down, left, and right). Given these restrictions, I imagine that…
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
2
votes
4 answers

finding whether a path of a specific length exists in an acyclic graph

In an acyclic graph, I am trying to find out whether or not a path of length L exists between two given nodes. My questions is, what is the best and the simplest Algorithm to use in this case. Note that the graph has a maximum of 50 nodes and 100…
2
votes
0 answers

How to get the longest path in a DAG starting at a fixed node?

I want to know how to get the longest path in a DAG starting from the node 0(the smallest node) I searched wiki and got the following algorithm: algorithm dag-longest-path is input: Directed acyclic graph G output: Length of the longest…
1
vote
4 answers

Longest path in graph

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.Formally,I want to implement heuristic for computing longest path,morever,if…
username_4567
  • 4,737
  • 12
  • 56
  • 92
1
vote
1 answer

Question about single source longest path in a DAG

If I am right, the problem of single source longest path for any general graph is NP-hard. Can we negate all the edge weights of a DAG and run Dijstra's or Bellman Ford algorithm to get single source longest path? If yes, Dijstra's can't run on a…
1
vote
1 answer

Example of longest path problem having a NP complexity?

I saw on the internet that finding the longest path problem is NP-Complete problem. For some reason, my teacher tells me that it isn't an NP-complete problem. So now I am looking for an example that shows the amount of computation needed for getting…
gabi939
  • 107
  • 2
  • 8
1
vote
1 answer

Proof the longest path is NP-Hard with negative edge weights

I know a similar question has been asked before and that there are abundant amount of resources online, but I have a slightly different question. I understand the reduction from HAM Path to Longest Path. It relies on both needing to use n-1 edges.…
John Doe
  • 113
  • 2
  • 7
1
vote
0 answers

GameplayKit Longest Path

I want to build GKGraph and find longest path between two points. I see that GKGraph has a method to find shortest path but for longest I didn't find anything. Can you suggest how can I find the longest path between two points using GameplayKit?
Karen Karapetyan
  • 704
  • 1
  • 9
  • 18
1
vote
1 answer

Prolog - longest sublist within a list

I am trying to get the longest sublist within a list. I need a rule that recursively searches a list of lists and determines which list has the longest length. For example: input: [[1],[1,2],[],[1,2,3,4],[5,6]] output: [1,2,3,4] This is what I have…
bcr
  • 950
  • 8
  • 28
1
vote
2 answers

Most inefficient algorithm to visit each elements of a 2d array once

I'm creating panorama images, and for this I use a camera that I move programmatically step by step. The images are captured rows by rows. So basically the captures can be seen as some kind a 2d array: [ 0, 1, 2, 3 ] # row 1 [ 4, 5, 6, 7 ] # row…
Silex
  • 1,707
  • 17
  • 24
1
vote
2 answers

Floyd-warshall for longest distance for undirected graph

I want to find the largest distance between any two vertices of a weighted undirected graph using Floyd-warshall algorithm. For this i have made few changes: I add negative weights instead of positive. Then i find out the shortest path. But it…
1
vote
1 answer

How can I convert every path of a directed weighted graph to equal cost ? (see description)

Can we convert a directed weighted graph in such a way that each of its path from a specified source to destination is of equal cost? The cost of each of the path should be equal to the maximum cost path in original graph. How to convert any…