Sage (not the accounting software, but sagemath.org) is accepted to Google Summer of Code 2012, and I will be one of many mentors.

## Posts Tagged ‘maths’

### Sage (sagemath.org) at GSoC 2012

19 March, 2012### Installing CPLEX 12.2 on Debian amd64 and MacOSX 10.6 (64-bit)

24 September, 2010IBM now gives CPLEX to academics for free; as I am computing LP bounds for quantum codes, I got myself one. However, it refused to install on my amd64 Debian system, saying

`"libgcc_s.so.1 must be installed for pthread_cancel to work"`

.

After much googling, it turned out that the installer is a 32-bit program, that needs the right 32-bit libgcc_s.so to work.

To get this on Debian (squeeze), I just did

`$ apt-get install ia32-libs`

Then

`$ LD_LIBRARY_PATH=/usr/lib32; `

sh cplex_studio122.acad.linux-x86.bin

worked as it should.

The installation goes smoothly on a 64-bit MacOSX 10.6. But running is not: one has problems when doing

>>> import cplex

...

from cplex._internal.py1013_cplex122 import *

ImportError: dlopen(/Library/Python/2.6/site-packages/cplex/_internal/py1013_cplex122.so, 2): no suitable image found. Did find:

/Library/Python/2.6/site-packages/cplex/_internal/py1013_cplex122.so: mach-o, but wrong architecture

One can make it work on by setting

`$ export VERSIONER_PYTHON_PREFER_32_BIT=yes`

before starting the Python session (as IBM/CPLEX Support kindly told me; they promised a fix in an upgrade, too).

### Is C++ the worst 1st programming language for maths majors?

7 May, 2010In our department we have a 1-semester course called “Introduction to scientific programming”, that is taught to the 1st year undergrads. It is C++-based. I am arguing for years that it is a real waste, and only good for getting people dazed and confused, and that instead something like Python should be used.

The choice of Python is basically due to it being interpreted, (largely) untyped, and higher level than C/C++.

(And last but not least, free, unlike Maple, Matlab, and Mathematica, which might be marginally more useful to a maths major).

Here is a ranking of programming languages in industry. Inevitably biased in some ways, I suppose it still demonstrates that claimed “superiority” of C++ is nowhere to be seen…

### Hungarian algorithm, take 1

23 September, 2009**Hungarian algorithm** is an efficient procedure to find a maximum weight matching in a bipartite graph with parts and and a weight function Usually it is described in terms of potential functions on and looks quite mysterious, as it hides the origin of the procedure, that is a variation of the augmenting path method for finding a maximum (unweighted) matching in Here we describe this point of view.

Let be a matching of maximum weight among all matchings of size If is a maximum (unweighted) matching then we are done.

Otherwise, we construct a bipartite digraph by orienting all the edges in from to and the remaining edges in the opposite direction. We also construct the length function by setting for all and for all Observe that there no negative length (directed) cycles in . Indeed, any directed cycle in contains equally many edges in from and in Note that would mean that and so is not maximum among all matchings of size as whereas

Let and be subsets of resp. that are unsaturated by We find (say, using the Bellman-Ford algorithm) a minimum length directed path between and By construction of is an augmenting path for So is a matching satisfying

Claim: is maximum among all matchings of size

We’ll prove this claim below. For now, we remark that it is obvious that this procedure, repeated with taking place of will find matchings of maximum weight among all matchings of size In the end it remains to select among these at most matchings one with maximum weight.

Now let us prove the claim. It certainly holds for as the procedure will select a maximum weight edge in and will consist of this edge. So we can assume Let be a matching of size and of maximum weight. We need to show that As in the subgraph there

exists a connected component that is a augmenting path

But is a shortest augmenting path, so

On the other hand, is a matching of size and so by induction. Now as claimed. QED.

As described, we need to do less that loops of this procedure. In each loop, the Bellman-Ford dominates the complexity, so in total we need operations. In fact, we can stop as soon as we reached the situation when

Let a matching have maximum among matchings of size and any matching of size satisfy Then for any matching of size bigger than

Proof. Suppose be a matching contradicting the claim, minimal w.r.t. Let be the digraph constructed from and as above. The connected components of induce oriented cycles and directed paths on Each such component will have a nonnegative total length, as neither there can be a negative length cycle in (see above) nor can there be a negative length -augmenting path (otherwise we can construct ). But this implies that contradiction. QED.

In particular, the complexity above can be improved to

### Bipartite matchings via linear programming

14 September, 2009An important tool for combinatorial optimisation problems, and graph problems among them, is **linear programming**, a method (and a problem) to find the optimum of a linear function on a polyhedron (i.e. on an intersection of half-spaces.) Often, such an intersection is bounded, and then one talks about a **(convex) polytope** rather than a polyhedron.

The optimum of a linear function on a polytope is always reached on a vertex, or, more generally, on a set of vertices of generating an optimal face. (A vertex is a point in that cannot be written as a nontrivial convex combination of two other points of )

Here we demonstrate a way to encode the problem of finding the size of a maximum matching (or, more generally, the maximum weight of a matching) in a bipartite graph as a linear programming problem.

As a warmup, we treat perfect matchings. Consider the vector of variables and the system of inequalities

Certainly, if is the characteristic vector of a perfect matching of i.e. is a 0-1 vector with 1s corresponding to the edges of it satisfies the system above. Thus maximizing the linear function on the polytope defined by gives an upper bound on the size of a maximum weight perfect matching in w.r.t. the edge weights

But in fact much more holds: namely, this bound is tight, as follows from the following theorem.

For a bipartite graph the vertices of the polytope defined by have 0-1 coordinates, and are in the one-to-one correspondence with the perfect matchings of

*Proof*. Let be a vertex of and be the support of i.e. Then does not contain a cycle. Indeed, a cycle in can be decomposed into the disjoint union of two (not necessarily perfect) matchings, say and as is bipartite and so each cycle in is even. Observe that for any

Thus there exists such that and so contradicting the assumption that is a vertex (and so it cannot be a convex combination of two points in ).

Thus is a forest. Let be a leaf of a subtree of Then implies that Therefore any connected component of is an edge, and so is a matching. It is a perfect matching by QED.

By this theorem, the maximum of on is reached on a perfect matching Another almost immediate corollary is the following well-known result on doubly stochastic matrices (an nonnegative real matrix is called doubly stochastic if its row and column sums are equal to 1.)

A doubly stochastic matrix is a convex combination of permutation matrices.

Indeed, -permutation matrices (the 0-1 doubly stochastic matrices) are in one-to-one correspondence to the perfect matchings of (the characteristic vector of such a matching can be viewed as an matrix, with rows corresponding to one part of the graph, and columns to the other) and so the doubly stochastic matrices are exactly the points of the perfect matching polytope of that has, by our theorem, perfect matchings as vertices (and so any point in it is a convex combination of perfect matchings).

**Excercise.** Formulate an analogy of system for matchings (not necessarily perfect) in bipartite graphs, and prove the corresponding result for vertices of the polytope in question. Using it, formulate the linear programming problem with optimal value being the size of maximum matching.

**Excercise.** Show that these constructions fail for non-bipartite graphs.

### 5-list-colouring of planar graphs

8 September, 2009A list-colouring of a graph with a colour list for is a proper colouring of by elements of so that the adjacent vertices are coloured in different colours and the colour for is in In particular, when all the s are equal to each other we have a classic graph colouring.

is called -choosable, or list-colourable if it is list-colourable for any satisfying for all The minimal for which is is choosable is called the list chromatic number of and denoted by Certainly,

It is not hard to construct examples when e.g. take and consider where vertices in the size two part of get colour sets .

Using the fact that each planar graph has a vertex of degree at most 5, as can be easily established using the Euler formula, one can prove that each planar graph is 6-choosable (employ induction by removing a minimal degree vertex).

It is less easy to show that

any planar graph is 5-choosable.

This was established in 1994 by Thomassen.

In fact cannot be improved — there are examples of planar for which The smallest known (in 2003) example has 63 vertices.

The classical analogy of this, the Heawood theorem that says that each planar graph is 5-colourable, is known since 1890, and the 4-colourability is a recent and quite difficult result by Appel and Haken.

To show the 5-choosability, one first observes that it suffices to prove it for the planar graphs for which every face, except possibly the exterior face of the plane embedding, is a triangle. We call such graphs almost triangulated. Then, one proceeds by induction on Assume that we know that for any almost triangulated planar with exterior face and such that for all resp. for all we can extend a proper -list-colouring of an edge on to a full proper -list-colouring (as is obviously true provided giving us a basis of induction).

Let us now show this for with Let be an edge of that we colour using and

If has a chord, i.e. there is an edge that joins two non-adjacent vertices of the cycle induced on (and so is not cutting through the fact bounded by the cycle on ), we spilt into two planar parts and so that and have in common. W.l.o.g. by induction, we can extend this colouring to a list-colouring of This colouring will fix a proper list-colouring of the edge that is on the exterior face of Again, by induction, we can extend this colouring of to a list-colouring of Combining and we obtain a list-colouring of as required.

It remains to consider the case when does not have a chord.

Then let be the vertex adjacent to Take any two colours in (this is possible as ) and remove from for all Then remove and all the edges on it from We obtain a planar graph with one vertex less, and with the valid exterior face conditions. By induction, we can extend the colouring of to a list-colouring of It remains to see that can be properly coloured, too. Indeed, we can colour it with either or depending on the colour of the neighbour of on distinct from Q.E.D.

### a subgeometry of D_3-dual polar space

29 May, 2009In 1991 I provided to Andries Brouwer more examples of distance-regular graphs that were not known at the time the book “Distance-regular graphs” by Andries, A.M.Cohen, and A.Neumaier, that he included into “Additions and corrections”. Recently I was asked for more details on these. So I started to recall what that was all about (I drifted quite far from that area of research since then, I must say)…

D_{3}-dual polar space is a bipartite graph that satisfies the following properties:

- each 2-path lies in a unique complete bipartite subgraph with parts of size
- for any vertex the edges and the subgraphs form a projective plane with respect to inclusion.

So from the point of view of Tits’ “local” approach to buildings we talk about a “geometry with diagram” where stands for a generalised 4-gon (and indeed complete bipartite graph is a trivial example of such a thing), and stands for a generalised 3-gon, i.e., a projective plane.

To construct a typical example, let us consider the case of the projective planes being of order Then we have a distance-regular graph of diameter 3, with distribution diagram around a vertex as follows:

[1]^{13}—^{1}[13]^{12}—^{4}[39]^{9}—^{13}[27]

So each vertex has 13 neighbours, 39 vertices at distance 2, and 27 at distance 3; each neighbour of has 12 neighbours at distance 2 from each distance 2 vertex has 4 mutual neighbours with and 9 neighbours at distance 3 from

Such a graph is unique: this is so for each a prime power, in fact, there is 1-to-1 correspondence between such graphs and 3-dimensional projective spaces: take as *points* (resp. *planes*) of the space parts of the bipartition, with incidence being the adjacency in and subgraphs as *lines*, with adjacency between *lines* and *points* (resp. *planes*) being inclusion.

And -dimensional finite projective spaces, for are all coming from the natural construction from the 4-dimensional vector space over a Galois field.

Another natural construction of comes from a non-degenerate 6-variate quadratic form, over of maximal Witt index (i.e. a form that cannot be rewritten as a form with lesser number of variables using a nondeg. linear transformation, and such that there are totally isotropic subspaces of dimension 3, the maximal possible in fact). Recall that a subspace is called totally isotropic w.r.t. to a form if for all

Then the vertices of are the maximal totally isotropic subspaces, with adjacency being the maximality of the intersection dimension (i.e. two vertices are adjacent iff the corresponding 3-spaces intersect in a 2-dimensional subspace).

** Example.** For one can take and a maximal totally isotropic subspace with a basis

The advantage of this construction is that it allows to describe dual polar graphs for as well. (Take -variate nondeg. form of maximal Witt index equal to , etc.)

We are interested in constructing a subgraph of that behaves

like when we look at the neighbours of with the difference that edges on and the subgraphs on now form an affine plane, not a projective one. So while In order to do so, we pick up an edge and remove from the latter all the vertices adjacent to either or The resulting graph is exactly that we want!

In terms of maximal totally isotropic subspaces, the vertices of are these ones that have 0 intersection with the 2-dimensional subspace corresponding to the intersection of the 3-dimensional subspaces corresponding to and We have a distance-regular graph of diameter 4, with distribution diagram (for ) around a vertex as follows:

[1]^{9}—^{1}[9]^{8}—^{3}[24]^{6}—^{8}[18]^{1}—^{9}[2]

It is a fold antipodal cover of , i.e. the vertices are partitioned into sets of size such that pairwise distances between vertices in each of them are maximal, i.e. 4, and there is a naturally defined structure of complete bipartite graphs on them.