DFS traversal algorithm


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: DFS traversal algorithm

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    DFS traversal algorithm

    i have No idea how to do this

    By modifying the DFS traversal algorithm, write pseudocode for an algorithm that determines whether a graph contains a cycle.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    the traversal is wired to touch every node once, or at least thats the usual defination of a traversal (?).

    There are several ways to do this, and better ways, but this is the simple one.

    Run the traversal, and at every node, create a list of what nodes are 1 step away from the current node. You now have a "map" of the entire graph; from any node, you can now "see" what nodes can be visited next. From that information, you should be able to build a test for a cycle.

Similar Threads

  1. Replies: 7
    Last Post: 03-17-2009, 01:40 AM
  2. Next Algorithm To Learn
    By Peter_APIIT in forum C++
    Replies: 4
    Last Post: 10-11-2008, 12:19 AM
  3. Tree Traversal Questions
    By beamer7296 in forum Java
    Replies: 1
    Last Post: 03-23-2006, 01:13 PM
  4. How to add third party algorithm in sql server 2000
    By shipra pandey in forum Database
    Replies: 0
    Last Post: 02-18-2006, 02:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center