Development Cycles
  Home arrow Development Cycles arrow Learning About the Graph Construct using G...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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? 
DEVELOPMENT CYCLES

Learning About the Graph Construct using Games, Part II
By: Mohamed Saad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 27
    2005-03-15

    Table of Contents:
  • Learning About the Graph Construct using Games, Part II
  • Dijkstra's algorithm
  • Algorithm in action
  • Floyd-Warshall algorithm
  • Back to the water problem

  • 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


    Learning About the Graph Construct using Games, Part II


    (Page 1 of 5 )

    In this second article in a three part series, we learn about two famous algorithms that can be used to solve the classic shortest path problem, and finally get the solution to the water jug division task set in the first part (no fair reading ahead to find it!).

    Welcome back! This is part two of the three part series entitled "Playing games with graphs." In part one, we gave an introduction to graphs, and introduced the problem of water division. We saw how we can construct the graph for this problem. Today, we are going to handle finding the shortest path from the source node to the destination node.

    Recall from part one that in the graph constructed, a node represented a state of the jugs. The initial state was "8","0","0" or 8 liters in the first jug, with other two jugs empty. We constructed a graph of all possible states that can be reached. We needed to find the shortest path from the node "8","0","0" to the node "4","4","0"

    Shortest path problem

    The shortest path problem is quite straightforward. Given two nodes in a graph, it is necessary to find the shortest path between them. Luckily for us, the shortest path problem is an easy problem to solve, unlike the longest path problem, which surprisingly, is a very hard problem to solve. This is one of the rare occasions in life where the more useful problem is also the easier one. But let's set theory aside for now, we have a task to do.

    There are two very famous algorithms for finding the shortest path in a graph. Those are the ones we are going to introduce here.

    The first algorithm starts with a node, and proceeds to find the shortest path from this node to all other nodes in the graph. This is called the single-source all-destination shortest path for obvious reasons. This algorithm was devised by Dijkstra.

    The other algorithm just finds the shortest path from every node in the graph to every other node. This is obviously called all-source all-destination. This algorithm was developed by Floyd and Warshall.

    As you may imagine, the Floyd-Warshall algorithm is a little harder to comprehend than Dijkstra's algorithm (simply because it does more). We are going to present both ideas first, and then we are going to show all the details behind Dijkstra's algorithm to solve the problem at hand.

    More Development Cycles Articles
    More By Mohamed Saad


     

    DEVELOPMENT CYCLES ARTICLES

    - Division of Large Numbers
    - Branch and Bound Algorithm Technique
    - Dynamic Programming Algorithm Technique
    - Genetic Algorithm Techniques
    - Greedy Strategy as an Algorithm Technique
    - Divide and Conquer Algorithm Technique
    - The Backtracking Algorithm Technique
    - More Pattern Matching Algorithms: B-M
    - Pattern Matching Algorithms Demystified: KMP
    - Coding Standards
    - A Peek into the Future: Transactional Memory
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - How to Strike a Match







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