Thread: All pathways algorithm

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Question All pathways algorithm

    Hey guys,
    I am a C noob so I have a pretty basic question. Does anyone know of a way to output all possible paths between 2 points on a graph. I know I can use either Floyd Warshall or Dijisktra to print out the shortest pathway, but I need all possible paths printed out in a single text file.
    I have been thinking about it for a couple of weeks now but I cant really find any thing. Could some C guru help me out? I don't need help with the code, but I would really appreciate some guidance as how to go about programming it or a pseudo code or perhaps an academic paper that deals with the topic.
    Thanks!

    Edit: My input is a matrix of distances between all possible nodes(imagine cities(a & b) as nodes and the distance between 2 cities as the matrix element ab)
    Last edited by hanniballector; 11-23-2010 at 09:16 PM. Reason: Needed to clarify input.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Go to Wikipedia, or Google, and search for Depth First Search and Breadth First Search. Both are fully exhaustive, if you don't stop them, and find every possible point.

  3. #3
    Registered User hellork's Avatar
    Join Date
    Nov 2010
    Posts
    39
    Consider a 2 x 2 grid. All possible paths from a to b would be a square.
    Code:
    a
    *--*
    |  |
    *--*b
    Now just recurse

    Sorry... I couldn't resist!

    Depends on whether or not you can cross paths.
    Last edited by hellork; 11-23-2010 at 09:20 PM.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    21
    Quote Originally Posted by Adak View Post
    Go to Wikipedia, or Google, and search for Depth First Search and Breadth First Search. Both are fully exhaustive, if you don't stop them, and find every possible point.

    The BFS algorithm looks promising. I will report back once I (hopefully) get it working. Thanks for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implement of a Fast Time Series Evaluation Algorithm
    By BiGreat in forum C Programming
    Replies: 7
    Last Post: 12-04-2007, 02:30 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM