Search
 
SCRIPT & CODE EXAMPLE
 

CPP

bfs sudocode

BFS (G, s)                   //Where G is the graph and s is the source node
      let Q be queue.
      Q.enqueue( s ) //Inserting s in queue until all its neighbour vertices are marked.

      mark s as visited.
      while ( Q is not empty)
           //Removing that vertex from queue,whose neighbour will be visited now
           v  =  Q.dequeue( )

          //processing all the neighbours of v  
          for all neighbours w of v in Graph G
               if w is not visited 
                        Q.enqueue( w )             //Stores w in Q to further visit its neighbour
                        mark w as visited.
Comment

PREVIOUS NEXT
Code Example
Cpp :: prevent copy c++ 
Cpp :: reference c++ 
Cpp :: how to access a vector member by its index 
Cpp :: use of strstr in c++ 
Cpp :: loop execution descending order in c++ 
Cpp :: draw line sfml 
Cpp :: c++ variable type 
Cpp :: max c++ 
Cpp :: c++ thread wait fro 1 sec 
Cpp :: converting char to integer c++ 
Cpp :: ue4 int to enum c++ 
Cpp :: c++ pass ofstream as argument 
Cpp :: read a whole line from the input 
Cpp :: Character cin(userInput) in c++ 
Cpp :: find an element in vector of pair c++ 
Cpp :: hide window c++ 
Cpp :: how to find size of int in c++ 
Cpp :: how to use power in c++ 
Cpp :: queue operations c++ 
Cpp :: c++ length of int 
Cpp :: C++ pointer to base class 
Cpp :: define a type in c++ 
Cpp :: ? c++ 
Cpp :: set to vector c++ 
Cpp :: using-controller-and-qt-worker-in-a-working-gui-example 
Cpp :: lap trinh file explorer c++ 
Cpp :: how-to-read-until-eof-from-cin-in-c++ 
Cpp :: how to pronounce beaucoup 
Cpp :: Summation of Natural Number Sequence with c and c++. 
Cpp :: move semantics in c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =