Questions tagged [longest-path]

106 questions
0
votes
2 answers

How to know max number of connected nodes in a graph-without going back to previous node

Suppose we need to draw a graph with many points. For example INPUT : {1#2,2#3,3#11,1#11,4#11,4#5,5#6,4#12} OUTPUT : 7 One node can be connected to many other nodes directly. We need to find the max connected nodes in this graph but not allowed to…
0
votes
2 answers

Trying to figure out longest path algorithm python

I'm trying to make a python script, that gets me the longest repeated character in a given matrix (horizontally and vertically). Example: I have this matrix: afaaf rbaca rlaff Giving this matrix for input, it should result: a 3 You can see that…
0
votes
0 answers

Algorithm to maximize number of traversed nodes

I'm trying to optimize a graph-traversal problem, but can't figure out the best way to tackle it. It seems neither like A* search problem (because we want to maximize the path rather than minimizing it), nor traveling salesman problem (because we…
0
votes
2 answers

Longest path (edge weight = 1) in Un-directed graph solution?

I have an un-directed graph that weight of each edge is 1. The graph may have cycles. I need to find a longest path in the graph (each node appear once). The length of the path is number of nodes. Any simple/effective solution? Thanks!
LHA
  • 9,398
  • 8
  • 46
  • 85
0
votes
2 answers

How can I calculate the shortest and longest paths of this Q&A flow?

I have a Q&A flow like the following: The basic idea is that depending on the answer chosen for a question, a different question will be asked next. I am currently representing this Q&A flow with the following JavaScript object: var QAndAObj = { …
HartleySan
  • 7,404
  • 14
  • 66
  • 119
0
votes
1 answer

Find distance from a node to the one farthest from it BOOST

I need to fin the distance from all nodes to the node farthest from it in the minimum spanning tree. I have done this so far but I got no clue as to find the longest distance from a…
rama
  • 45
  • 1
  • 1
  • 6
0
votes
2 answers

Longest path for weighted directed acyclic graph

I'm trying to conceptualize this problem and then write Java code for it. I know there's been some discussion here, but I'm not seeing lots of answerers, so I'd like to reiterate the question by writing out my thoughts and I'm hoping to gain some…
blazonix
  • 393
  • 2
  • 5
  • 15
0
votes
1 answer

Algorithm for Finding Longest Stretch of a Value at any Angle in a 2D Matrix

I am currently working on a computer-vision program that requires me to determine the "direction" of a color blob in an image. The color blob generally follows an elliptical shape and thus can be used to track direction (with respect to an initially…
JT Cho
  • 263
  • 1
  • 4
  • 11
-1
votes
1 answer

Time and Space Complexity of my Algorithm

I want to know what the time and space complexity of my algorithm will be. The input is a list of songs, and the output is the longest list of songs in which the last word of a song is the same as the first word of the next song. So for example, if…
-1
votes
1 answer

Longest route in a Matrix with hurdles (0 ,1) in python

The problem is how to find the longest route in a matrix of 0 and 1 We don't have any destination and source , We must find the longest possible route with 1 in matrix For example in matrix below , the length of our longest way is 8 : 1 0 0 1 1 0 0…
MSH
  • 5
  • 1
-1
votes
3 answers

Find longest sequence of decreasing numbers given a 2D matrix

Given a 2D array, find the longest sequence of decreasing numbers. Constraints are: 1. you cannot compare elements diagonally. For Eg: 56 14 51 58 88 26 94 24 39 41 24 16 8 51 51 76 72 77 43 10 38 50 59 84 81 5 23 37 71 77 96 10 93 53 82 94 15 96…
0726
  • 315
  • 2
  • 13
-1
votes
1 answer

python DFS directory and Print out the longest path

I meet some problems here. I can search all the directory and print it out, but I just cannot find the longest path. Here is my terminal stats. 14102 1 1 /home/bob/Desktop import os def DFS(path, dirCallback = None, fileCallback = None): stack…
-2
votes
1 answer

K longest paths in a DAG

I want to find K longest paths in a Directed Acyclic Graph (DAG). I have read few articles about it but I couldn't find any actual code that has implemented it. Can somebody help me with a python or pseudo code? Here is one interesting algorithm…
-2
votes
1 answer

Index out of bounds error for DAG

I'm writing a program to find the longest path for a DAG with input from standard in.I finally got it to compile, with it saying it is using unchecked or unsafe operations due to my Array list, but I am getting an index out of bounds error and it…
-2
votes
2 answers

How to find the longest simple path (including all intermediate nodes) in a directed cyclic graph?

I've searched on here for how to find the longest simple path in a directed cyclic graph (simple meaning that each node is visited only once, to avoid the path being infinite), and have came across solutions like this. All such solutions I've found…
LogicChains
  • 4,332
  • 2
  • 18
  • 27