Development Cycles
  Home arrow Development Cycles arrow Page 4 - 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  
Moblin 
IBM® developerWorks 
Sun Developer Network 
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 1
By: Mohamed Saad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 18
    2005-02-23

    Table of Contents:
  • Learning About the Graph Construct using Games, Part 1
  • Representing a Graph
  • Adjacency List Representation
  • Variations on graph representation
  • Weighted Edges
  • Labelled nodes
  • Building the Graph

  • 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 1 - Variations on graph representation


    (Page 4 of 7 )

    Not all graphs are created equal! The nature of a graph varies widely by the nature of the problem we are trying to solve. Here we give the three most important variations, and how we can handle them.

    Directed vs. Undirected Graphs

    This is by far the most important variation. In our previous examples we were basically dealing with directed graphs; the word directed here refers to the edges. In all of the examples we have seen, edges had directions. An edge going from A to B is not necessarily also going the other way round. All our examples were based on this.

    But, in real life, it doesn’t always work that way. In certain applications, the edges of a graph could have no specific direction. An edge just connects two nodes, and the direction is not important. This is the case with undirected graphs.

    An example of a problem with directed graphs is the problem of World Wide Web representations, where pages are represented as nodes, and links are represented as edges. Clearly the direction of a hyperlink matters. If your site links to the Yahoo homepage, it does not mean the same thing as Yahoo putting a link to you on its front page! This is a typical example of a directed graph.

    An example of an undirected graph is the initial example we gave about cities, and highways, where cities were represented as nodes, and highways represented as edges. We were interested to find the shortest path from city A to city B. In this example, there are no clear directions for edges. A highway connects two cities, and that’s pretty much it. (Well… I never heard about one way highways anywhere in the world. Please email me if you know any!)

    Now, all of our discussion until now was about directed graphs. How can we handle undirected graphs? Should we throw everything out and start over? Absolutely not!

    Basically to represent an undirected graph, we use either of the two methods explained above (adjacency lists and adjacency matrices), but for every edge, we actually add two edges in the graph. For example, to add an edge between A and B, we add an edge from A to B, and an edge from B to A.

    We have to be careful though, because this approach can cause problems later if we are not careful. It is important to think of both edges as just one edge, not two. Any operation that is done to one must be done to the other.

    By the way, directed graphs are drawn without any arrows on the edges. This is to indicate the edges have no specific direction.

    More Development Cycles Articles
    More By Mohamed Saad


     

    DEVELOPMENT CYCLES ARTICLES

    - 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
    - Entity Relationship Modeling
    - Tame the Beast by Matching Similar Strings






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT