DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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, 12:40 AM
  2. Next Algorithm To Learn
    By Peter_APIIT in forum C++
    Replies: 4
    Last Post: 10-10-2008, 11:19 PM
  3. Tree Traversal Questions
    By beamer7296 in forum Java
    Replies: 1
    Last Post: 03-23-2006, 12: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, 01:40 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links