Thread: Recursive Depth Fisrt Search

  1. #1
    Registered User
    Join Date
    Jun 2014
    Posts
    3

    Recursive Depth Fisrt Search

    Can anybody give me a C Code to find all possible paths between two nodes?I have a adjacency matrix.(adjacency matrix occurs 0 and 1)

    all paths between 1 and 4 are:

    1-2-3-4
    1-2-4
    1-3-4
    1-3-2-4

    Code:
    int visited[2415]={0};
    Code:
    void DFS(int i,int target)
    {
    
        int j;
        
        if(i<=target)
        printf("%d ",i);
        visited[i]=1;
        for(j=0;j<2415;j++)
            if(!visited[j]&&graf[i][j]==1)
                DFS(j,t);
    
    
    }
    How should I change this code?
    Last edited by unhappyhuman; 06-11-2014 at 04:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. depth-first search of a graph
    By evinda in forum C Programming
    Replies: 1
    Last Post: 05-20-2013, 08:27 AM
  2. Depth First Search problem
    By UltimoBrah in forum C Programming
    Replies: 1
    Last Post: 03-12-2013, 11:18 AM
  3. Help with Depth First Search
    By [Student] in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2012, 12:28 PM
  4. Depth-first search & TSP
    By Cpro in forum C++ Programming
    Replies: 12
    Last Post: 12-13-2008, 12:51 PM

Tags for this Thread