4

BFS & amp; DFS - What summit to start?

 2 years ago
source link: https://www.codesd.com/item/bfs-dfs-what-summit-to-start.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

BFS & amp; DFS - What summit to start?

advertisements

I've read pages and pages of information on BFS and DFS algorithms. What none of them say, is which vertex to choose first?

For instance, in this image, do the arrows mean you cannot traverse from c to b, but can traverse from b to c?

RB627.png

Your help is much appreciated, friends.


If it's not a directed graph, it doesn't matter. The graph you posted is a directed graph which means exactly what you've stated. You can go from a to b but not from b to a.

Regarding which node to choose in a directed graph, every node you'll choose can produce different result. Usually under these circumstances it's best to start from the root node if it's given.

Related Articles

Using BFS or DFS to determine connectivity in an unconnected graph?

How can i design an algorithm using BFS or DFS algorithms in order to determine the connected components of a non connected graph, the algorithm must be able to denote the set of vertices of each connected component. This is my aproach: 1) Initialize

Printing permutation using bfs or dfs

I am trying to print all the permutations of a string using recursion as below. But I was wondering if we can use bfs or dfs also to do this, am I thinking right? If yes, then can you please give me an idea? My idea is: if string = "abcd" start

How to build a tree with its BFS and DFS traversal

I have the BFS and DFS traversal of a tree. How can I reconstruct the tree from these traversals? For example: BFS Traversal : 4 3 5 1 2 8 7 6 DFS Traversal : 4 3 1 7 2 6 5 8 then the tree would be like bellow: 4 / \ 3 5 / \ \ 2 1 8 | | 6 7 This is o

Application of BFS or DFS

I need help in solving this problem, I tried using a 2D array and then finding the least number of swaps. Not sure exactly how to go about this problem. Whether to use BFS or DFS? You are given two four digits numbers. The first number is the initial

Find a cycle in a directed graph using BFS or DFS

I tried looking around the Internet but I'm a little stuck at the moment with regards to modifying the BFS or DFS algorithm in order to be able to find a cycle in a directed graph. If the graph were not directed, the DFS algorithm would solve this us

Difference between BFS and DFS

I am reading about DFS in Introduction to Algorithms by Cormen. Following is text snippet. Unlike BFS, whose predecessor subgraph forms a tree, the predecessor subgrpah produced by DFS may be composed of several trees, because search may be repeated

I can not understand how Prolog knows what is the start state in a DFA acceptance rule

I worded the title the best way I could think of, but let me make it clear. When programming a DFA in Prolog, here is a typical manner of doing so: start(q0). final(q2). transition(q0, a, q1). transition(q1, b, q1). transition(q1, c, q2). accept(Symb

What does Java start the heap if I do not specify an -Xms?

Possible Duplicate: How is the default java heap size determined? Im curious what happens if I do not specify a -Xms for initial JVM heap size with Java? Currently I have -Xms256m and -Xmx512m but this gives me an error on my server : Failed to creat

What is ApnsService.start used for in notnoop javapns? I can press msg with the push method without starting ()

sv = APNS.newService() .withCert("./dev.p12", "pwd") .withSandboxDestination() .build(); I just use sv.push(token, payload) without sv.start(), it seems that it worked well. So what's the use of start() and stop()? Should I add them in

At what age will you start teaching your child programming? What language to start?

It comes to my mind... should I start to teach my nephew programming at age of 5 instead of learning piano.... Do you think a 5 years old kid likes printf("Hello World!!") thingy... Just my thought.This is kind of a subjective question, but if I

What is & ldquo; Started with a change SCM & rdquo; in Hudson?

I was trying to find out who triggered the failing Hudson build. But i found Started by an SCM change instead of Started by 'UserId'. Now, what does that mean?It means that someone checked in code changes to your version control system / software con

What do the 'start' and 'length' attributes mean in LocalVariableTable?

So here is the example: LocalVariableTable: Start Length Slot Name Signature 0 133 0 this Lcom/my/class/Test; 2 131 1 a I 4 129 2 b I 7 126 3 i I 10 123 4 i2 I 16 117 5 o1 Ljava/lang/Integer; 31 102 6 o2 Ljava/lang/Integer; What does start and length

What is the starting angle and end angle of the bow in the html5 fabric?

I'm learning HTML5 and I"m stuck on arc. syntax arc(x, y, radius, startAngle, endAngle, anticlockwise) I'm not getting this startAngle,endAngle perfectly how this two parameters are calculated to draw different types of circles,arcs?This method takes

What should I start developing for iPhones?

I currently have Delphi 2010 and have just recently got an iPhone (5 days ago) which is my first ever venture into the Mac world. I absolutely love it btw - it has changed my life already. If this should be posted somewhere else then I apologise and

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK