Code Examples
  Home arrow Code Examples arrow Breadth-First Search in Graphs
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Breadth-First Search in Graphs
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-05-11

    Table of Contents:
  • Breadth-First Search in Graphs
  • Breadth-first approach in more detail
  • Classification and the Code Snippet
  • Inevitable Vertexes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Breadth-First Search in Graphs


    (Page 1 of 4 )

    Me, you and everyone is constantly searching for something: a new relationship, knowledge, music, food or just for a new experience. If we start to think about it, searching slowly becomes our second nature and takes up a good portion of our life, becoming a central motive for us. In the world of graphs, searching is just as important. Today we are going to examine the breadth-first search algorithm (BFS).

    This article is part of a series I am dedicating to graphs, so if you missed any of the previous ones you may want to read them. You can find them by clicking on my name or just start up a search on the site.

    If you have just heard the word "graph" and know little about the field of graphs, please make the effort to read the introductory article entitled An Insight into the Graphs.

    For now, let us focus on the search algorithms. Mainly there exist two kinds of search algorithms: the breadth-first search and the depth-first search. All the rest are variations on these. With small modifications to these two, you can solve a wide range of problems, as I will show you later on.

    Searching a graph means starting from a point and visiting all of the vertexes within a graph through the edges that exist between them. The depth-first search will be the subject of a future article, so for now let us focus on the breadth-first search.

    The theory behind it is simple. It can be summed up in the following sentence: step in at the root item (from the vertex we start to visit/search the graph), drop by all of its neighbors that have not been visited yet, and then continue the algorithm on the neighbors until all of the vertexes have been touched.

    More Code Examples Articles
    More By Gabor Bernat


     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek