Thread: DFS

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    38

    DFS

    If I do a DFS (Depth first search on a undirected graph) I can get different solutions, or is there still only one solution?

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    12
    Depends on the node you start with. If you start with the same node, then there is one solution.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You could do DFS in reverse order, which obviously gives a different ordering.
    However, yes DFS is deterministic. It will give the same result when done multiple times on the same tree. Why wouldn't it?!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. is my DFS coorect?
    By dpp in forum C++ Programming
    Replies: 5
    Last Post: 03-07-2009, 06:20 AM
  2. Problem using DFS with a DAG graph
    By incognito54 in forum C Programming
    Replies: 2
    Last Post: 05-11-2005, 06:16 AM