First verify that the graph doesnt have the cycles using BELLMAN-FORD
ALGORITHM. then apply DFS.. this will certainly give you a right answer...

On Thu, Feb 23, 2012 at 10:01 AM, atul anand <atul.87fri...@gmail.com>wrote:

> @saurabh :Even if you are considering its as a graph with no cycles ,  you
> should take care of the cycle its good practice esp in real world
> applications. Take it as an error check , beacuse you can never trust the
> person giving the input.you may not expect it but still have have it.
> so in case of cycle , remove that cycle.
>
>
> On Thu, Feb 23, 2012 at 7:12 AM, saurabh singh <saurab...@gmail.com>wrote:
>
>> In case cycle is present in the graph then we cant have a longest path in
>> the graph.Therefore the problem reduces to the longest path in a
>> tree.(Assuming the graph is connected).
>>
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT
>> blog:geekinessthecoolway.blogspot.com
>>
>>
>>
>> On Wed, Feb 22, 2012 at 11:23 PM, Don <dondod...@gmail.com> wrote:
>>
>>> Beware of cycles.
>>> Don
>>>
>>> On Feb 22, 6:05 am, krishna kishore <kknarenkris...@gmail.com> wrote:
>>> > Hi Gentle Men, Can any Please let me know How to Find a LONGEST PATH
>>> in a
>>> > Graph ( directed or Undirected but unweighted ).
>>> > INPUT: we have to give the Source vertex and Destination Vertex.
>>> > OUTPUT: it should include the LENGTH OF PATH and PATH as well.
>>> > Remember the graph should not be weighted.
>>> >
>>> > Any suggestions are accepted for sure.
>>> > And Thanks in Advance.
>>> > --
>>> >
>>> > *Vignesh*
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to