[Tutor] Graph theory

Michele Alzetta michele.alzetta at gmail.com
Thu Dec 4 02:03:03 CET 2008


Hallo all! It's a long time since I last wrote here.

I have been thinking about a problem, and I'm wondering what the best
approach for a pythonic solution would be.
The actual problem is very complex, but the very first step in the
solution would be to come up with a simple way of handling graphs.

For example, given that:
Definition 1: A network is a figure made up of points (vertices)
connected by non-intersecting curves (arcs).
Definition 2: A vertex is called odd if it has an odd number of arcs
leading to it, other wise it is called even.
Definition 3: An Euler path is a continuous path that passes through
every arc once and only once.

Given the following theorems:
Theorem 1: If a network has more than two odd vertices, it does not
have an Euler path.
Theorem 2: If a network has two or zero odd vertices, it has at least
one Euler path. In particular, if a network has exactly two odd
vertices, then its Euler paths can only start on one of the odd
vertices, and end on the other --  (Euler circuit).

Which would be the best approach for representing figures such as
those found here (  http://mathforum.org/isaac/problems/bridges2.html
) such that one could elaborate a script capable of finding and
describing paths in the figure? For example, Euler paths.

I realize that it is quite feasable to do this, but would take a lot
of coding - vertices and arcs could be represented as instances of
respective classes, and so forth.
But is there an elegant and simple solution already out there?

-- 
Michele Alzetta


More information about the Tutor mailing list