Development Cycles
  Home arrow Development Cycles arrow Page 2 - 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  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
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 III
By: Mohamed Saad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2005-03-22

    Table of Contents:
  • Learning About the Graph Construct using Games, Part III
  • Conditions for a Solution to Exist
  • Representing the Problem as a Graph
  • The Steps Required
  • Depth First Traversals
  • Solving the 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 III - Conditions for a Solution to Exist


    (Page 2 of 6 )

    We have just defined the problem. As you may have noticed, this problem is very famous, and is repeatedly published in kids' magazines. But, did you know these paths have a name of their own? They are called Euler tours. Euler discovered a way to solve this problem a long time ago, and found the conditions for a drawing to have a solution.

    Let's begin at the beginning. What are the conditions for a drawing to have an Euler tour? If we answer this question, finding the tours themselves will be an extremely easy task.

    In fact, to know if a drawing has an Euler tour we do the following:

    1. For every point, count the number of lines coming out of this point.
    2. If every single point has an even number of lines coming out of it, then this drawing has an Euler tour.
    3. If exactly two points have an odd number of lines coming out of them, while all others have an even number of lines coming out of them, then this drawing has an Euler tour.
    4. In all other cases, the drawing doesn't have an Euler tour.

    Why is that? It is not as hard as it looks. First, every time you pass through a point and get out, you add two lines to the count of lines coming out of this point. So, except for the very first point and the very last point, all other points should have an even number of lines coming out of them.

    What about the first and last points? These have one line coming out of them (the first point), or going into them (the last point), so we could have only two points having an odd number of lines coming out of them.

    The other case is when the first point is the same as the last point. So, now, all points have an even number of lines coming out of them, and the problem still can be solved.

    Great, now by looking at any drawing, we can very easily determine if it has an Euler tour or not. For example, this figure:

    Doesn't have an Euler tour, since the four corners of the square have five lines each. To be honest with you, some guy gave me this problem when I was a kid, and it took me three days of hard work, before I gave up and realized that it was impossible! If I had known the rules above, I wouldn't have wasted all that time!

    Now, we turn our attention to the serious problem of finding the actual tour -- in other words, to drawing the figure without passing over any line twice.

    More Development Cycles Articles
    More By Mohamed Saad


     

    DEVELOPMENT CYCLES ARTICLES

    - 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
    - 5 Web Design Tips You Can't Live Without
    - Practising Best Practises in Your Software D...
    - The Art of Modelling: Part 1
    - Thoughts on the Craft of Programming: Abstra...
    - Hi 5: Part 4







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway