Re: Longest path
- From: "Spiritus" <Spiritusp@xxxxxxxxx>
- Date: 31 Mar 2007 09:17:19 -0700
For the first problem, it is equivilent to finding shortest path for a
similar graph with all edges values negated. Problem is, you can't use
dijkstra, because there might be negative-sum circules, which is a
problem, since the shortest path will go through this circle inifinte
number of times. You can use Bellman-Ford though, which works a little
slower (O(VE)), but finds out if there are negative-sum circles.
Im not sure, but you asked for an algorithm to find the longest SIMPLE
path, so you might wanna find one even though there is a negative-sum
circle, so that's gonna be a problem.
For the second problem, If I understand you correctly, you want to
find whether a graph has two parts which are not connected by any
edge. You can just do a DFS starting from an arbitrary vertex, and if
you still have uncolored vertices, then this graph can be divided into
two (or more) parts.
.
- References:
- Longest path
- From: Mahdi
- Re: Longest path
- From: Raghu V. Hudli
- Longest path
- Prev by Date: Re: My LP Formulation of the TSP: Conclusions
- Next by Date: Re: Longest path
- Previous by thread: Re: Longest path
- Next by thread: Re: Longest path
- Index(es):
Relevant Pages
|