Graph theory in Formula 1

This post attempts to visualize Formula 1 championships (1985-2019) by way of graphs: the outcome of each race is represented by an edge between the drivers who finished #1 and #2. The graph is undirected (no distinction between the winner and 2nd place is made), and simple (no record of multiple edges is kept). This erases some of the information, but depending on how much you care about F1, the graphs may still be enough to bring back some memories.

All graph-theoretical “records” are based on 1985-2018 data only, 2019 season being in progress. Some highlights:

  • Most vertices: 12 in 1997
  • Fewest vertices: 5 in 2000 and 2011
  • Most edges: 16 in 2012
  • Fewest edges: 6 in 1988, 2002, 2011, and 2015
  • Largest maximal degree: 6 in 1990, 1997, 2004, and 2012
  • Smallest maximal degree: 3 in 1996
  • Largest minimal degree: 2 in 1989, 2016, and 2018
  • Largest diameter: 6 in 2009
  • Smallest diameter: 2 in 1993, 2000, 2001, 2002, 2007, 2011, and 2016
  • Disconnected: 1985, 1991, 1996, 1998, 1999, 2006, and 2008
  • Isomorphic seasons: 1991 and 1998
  • Hamiltonian cycle: 2016 and 2018
  • Triangle-free: none (hence no trees and no bipartite graphs)

Appropriately, both Hamiltonian cycles include Hamilton.

1985 season

 

year1985

This was the year of Senna’s first race victory, but the championship went to Prost, who shared maximal vertex degree (4) with Rosberg (Keke Rosberg, of course, not his son Nico Rosberg). This is also one of the few seasons with a disconnected graph. A small connected component, such as Angelis-Boutsen here, likely indicates something weird… in this case, the 1985 San Marino Grand Prix at Imola where Senna ran out of fuel and Prost was disqualified.

1986 season

year1986

Prost won again, this time with vertex degree 5.

1987 season

year1987

The four-way battle between Mansell, Piquet, Prost, and Senna fell just short of creating a complete subgraph on four vertices. Their best chance of creating {K_4} was at Detroit, where Senna won and Prost was 3rd. Piquet won the championship.

1988 season

year1988

The graph is smaller than the previous ones, but is actually larger than one would expect, considering that Senna and Prost combined for 15 wins in 16 races. Berger extended this graph by his win at Monza, in the season otherwise dominated by McLaren. The graph also suggests that Prost should win the championship, and he would have if the champion was determined by the total of all points earned as it is now. But only the best 11 results counted then, and Senna won by that metric.

1989 season

year1989

Again just an edge short of {K_4} subgraph, but this time it was not a four-way battle at all. Berger only finished 3 races (but in top two every time). Senna and Mansell also had too many retirements to challenge Prost for the championship. This is the first time we see a graph with no vertices of degree 1. But there is no Hamiltonian cycle here.

1990 season

year1990

The first time we see a degree of vertex 6, and the second time Senna is the champion.

1991 season

year1991

Another disconnected graph, with Piquet scoring his last career victory in Canada under strange circumstances: Mansell’s car stopped on the last lap when he led by almost a minute and was already waving to the crowd.

If such a mishap also happened at Silverstone, where Mansell, Berger, and Prost finished 1-2-3, we would have {K_4} as a subgraph. Senna won the championship for the last time.

1992 season

year1992

Sorry about Schumacher’s name being cut off… this was the year of his first race win, at Spa-Francorchamps. Meanwhile, Mansell utterly dominated the championship.

1993 season

year1993

The first time we get a graph of diameter 2. It suggests Hill was the winner, but in reality he finished third in the championship, with Prost winning for the last time in his career.

1994 season

year1994

The year of Senna’s death; he does not appear on the graph. Hill has the vertex degree of 5, but Schumacher won the championship by 1 point after their controversial collision at Adelaide.

1995 season

year1995

That’s pretty close to the wheel graph on six vertices – the only missing edge is Häkkinen-Coulthard. They would score a lot of 1-2 finishes for McLaren in the years to come, but at this time they were not teammates yet. At the center of the incomplete wheel, Schumacher won the championship by a wide margin.

1996 season

year1996

Another small component, another highly unusual race: wet Monaco Grand Prix, where only three cars made it to the finish and Panis scored the only victory of his career.

Hill won the championship in which no driver had vertex degree greater than 3, the only such season in our record.

1997 season

year1997

This season holds the record for the number of vertices (12). Two vertices have degree 6 (Villeneuve and Schumacher) but surprisingly, there is no edge between them. Although one of them was on the podium in every race except Italy, they were never on the podium together. Their infamous collision in the season finale at Jerez led to Schumacher being disqualified from the championship.

Villeneuve became the last non-European F1 champion to date.

1998 season

year1998

The small component is due to Carmageddon on the first lap of very wet Belgian Grand Prix.

This is where my decision to include only driver’s last names backfires: Ralf Schumacher gets to keep his initial. In other news, Williams suddenly faded from the picture and McLaren re-emerged with Häkkinen and Coulthard finishing 1-2 in five races. Häkkinen won the championship.

The seasons 1991 and 1998 is the only pair of isomorphic graphs in this collection. An isomorphism maps Schumacher and Häkkinen to Senna and Mansell.

1999 season

year1999

The small component is contributed by the partially wet Nürburgring race, where multiple retirements among the leaders left Herbert to score his last Grand Prix victory.

Schumacher’s injury at Silverstone took him out of contention. Still, the second championship of Häkkinen was a lot closer than the first one: he won by 2 points over Irvine.

2000 season

year2000

Finally, we get a complete subgraph on four vertices: the Ferrari and McLaren drivers. The sole appearance of a driver outside of these two teams was at Brazilian Grand Prix, where Fisichella finished 3rd but was promoted to 2nd after Coulthard’s disqualification. If not for this incident, we would have a regular graph in this collection, a rather unlikely event. Even so, this season set the record for fewest vertices (5). A closely fought championship ended with Schumacher collecting his third title.

2001 season

year2001

This was not close at all: the driver at the center of this diameter 2 graph won with a lot of room to spare.

2002 season

year2002

Another season of diameter 2. Schumacher finished every race in top two, except for the Malaysian Grand Prix, narrowly missing an opportunity to create a tree (a star graph). This season ties the fewest edges record (6) which was set in 1998.

2003 season

year2003

More vertices and larger diameter indicates a more interesting season. Schumacher won again, but by mere 2 points over Räikkönen.

2004 season

year2004

The final season of Schumacher/Ferrari dominance, in which Schumacher won 13 races and achieved the vertex degree of 6.

2005 season

year2005

This looks like it was between Alonso and Räikkönen – and it was, with Alonso becoming the youngest F1 champion yet.

2006 season

year2006

Button’s first career win (wet Hungarian Grand Prix) created the small component.

The large component has diameter 2, with Alonso (the champion) in its center. This is also the last graph in which Schumacher appears.

2007 season

year2007

As in 2000, Ferrari and McLaren combine to form a complete subgraph on four vertices. But this championship fight was as close as one could imagine, with three drivers finishing within one point: Räikkönen 110, Hamilton 109, Alonso 109. And this was Hamilton’s first season in F1.

2008 season

year2008

For the first time, we have a small component with more than two vertices. Kovalainen’s only F1 victory came in Hungary, where Glock took second place. More notable was Vettel’s first victory, which came in Monza and made him the youngest driver to win a F1 race [up to that time]. Even more notably, Hamilton won the championship by one point, at the end of the final lap of the final race, and became the youngest F1 champion at that time. Here is the Glock’s view of the action, his car slip-sliding on dry-weather tyres.

On the graph, “Jr.” is Piquet Jr. who took second place in Germany but his brief stint in Formula 1 would be remembered for an entirely different reason.

 

2009 season

year2009

The graph of largest diameter (6) captures a strange season after major rule changes. It is so close to being a complex tree, but the 3-cycle was completed at Istanbul, where the polesitter Vettel lost the lead on the first lap and then fell behind his Red Bull teammate Webber as well, finishing just 0.7 seconds behind in the 3rd place. If Vettel was first or second in Turkey, we would have a tree. Button won the championship on the strength of the first half of the season.

2010 season

year2010

The third time we see a {K_4} subgraph, but the first time that it involves more than two teams: the vertices come from Red Bull (Vettel and Webber), McLaren (Hamilton), and Ferrari (Alonso). Although Vettel’s vertex degree is only 3, trailing Hamilton’s 4 and Alonso’s 5, he became the youngest F1 champion in history, a record he still holds.

2011 season

year2011

The season tied 2000 for the fewest vertices, with 5. The fewest edges record (6) is tied as well: it was McLaren in 1988 and Ferrari in 2002; this time it is Red Bull’s turn. Vettel won the championship by 122 points but it’s not all in the car; his teammate Webber finished only third.

2012 season

year2012

With 16 edges, this season beat the previous record set by 1997 season, even though there are fewer vertices here. The two degree-6 vertices led the way in the championship, with Vettel beating Alonso by 3 points. Was this the last great season to watch?

2013 season

year2013

Vettel over Alonso again, but by 155 points this time. This was the last season of V8 engines, and last season of Red Bull domination. Hamilton appears on the graph only because of his victory in Hungary, after which Vettel won the remaining 9 races. The season opener turned out to be the last race [at the time of writing] won by someone not driving Mercedes, Ferrari, or Red Bull:

2014 season

year2014

The beginning of a new era: V6 hybrid engine, Mercedes, and Hamilton. Also the last time we see a McLaren driver (Magnussen) on the graph: he appears because of the 2nd place in the dramatic season opener.

In a brief moment of Williams resurgence, Bottas took 2nd place in Britain and Germany, forming a cycle with the Mercedes drivers. If not for him, we would have a tree.

2015 season

year2015

Another 6-edge graph, another season without much competition. Vettel was the only driver to challenge Mercedes on occasions, thus contributing a cycle to the graph. The entire graph is formed by Mercedes, Ferrari, and Red Bull. Hamilton won the championship again.

2016 season

year2016

The first time we get a Hamiltonian cycle, for example: Hamilton, Vettel, Rosberg, Räikkönen, Verstappen, Ricciardo, and back to Hamilton. Another 6-vertex graph formed by Mercedes, Ferrari, and Red Bull exclusively. Among them, Mercedes and Red Bull drivers form a complete subgraph. With Ferrari fading to third, neither Vettel nor Räikkönen had enough success to extend {K_4} to {K_5} and thus create the first non-planar season. We would have {K_5} if (a) Räikkönen overtook Verstappen in Austria (he was 0.3s behind), after Hamilton and Rosberg collided on the last lap:

and (b) Räikkönen finished 2nd instead of the 4th in Malaysia, where Hamilton’s engine went up in smoke, costing him the championship.

As it happened, we did not get {K_5} and Hamilton did not get the championship, which went to Rosberg instead. But Verstappen got his first victory at Barcelona and still remains the youngest driver ever to win an F1 race.

2017 season

year2017

Once again, it is all about Mercedes, Ferrari, and Red Bull, with the Mercedes drivers enjoying higher vertex degree. But this time Ferrari drivers are connected by an edge. The last 1-2 finish of Ferrari to date was in Hungary, arguably their high point of the season.

It was all about Hamilton the rest of the season.

2018 season

year2018

Second time a Hamiltonian cycle appears, for example: Hamilton, Räikkönen, Verstappen, Vettel, Ricciardo, Bottas, and back to Hamilton. Fourth year in a row that only Mercedes, Ferrari, and Red Bull drivers appear on the graph. Second year in a row that Hamilton wins, and his fifth time overall.

2019 season (after 7 races)

year2019

We still have a chance to get a tree, or to set new records for fewest vertices or fewest edges. I will update this at the end of the season.

Laplacian spectrum of small graphs

This is a collection of entirely unoriginal remarks about Laplacian spectrum of graphs. For an accessible overview of the subject I recommend the M.S. thesis The Laplacian Spectrum of Graphs by Michael William Newman. It also includes a large table of graphs with their spectra. Here I will avoid introducing matrices and enumerating vertices.

Let {V} be the vertex set of a graph. Write {u\sim v} if {u, v} are adjacent vertices. Given a function {f\colon V\to \mathbb R}, define {L f(v) = \sum_{u\colon u\sim v}(f(v)-f(u))}.
This is a linear operator (the graph Laplacian) on the Euclidean space {\ell^2(V)} of all functions {f\colon V\to \mathbb R} with the norm {\|f\|^2 = \sum_{v\in V} f(v)^2}. It is symmetric: {\langle L f, g\rangle = \langle f, L g\rangle } and positive semidefinite: {\langle L f, f\rangle = \frac12 \sum_{u\sim v}(f(u)-f(v))^2\ge 0}. Since equality is attained for constant {f}, 0 is always an eigenvalue of {L}.

This is the standard setup, but I prefer to change things a little and replace {\ell^2(V)} by the smaller space {\ell^2_0(V)} of functions with zero mean: {\sum_{v\in V}f(v)=0}. Indeed, {L} maps {\ell^2(V)} to {\ell^2_0(V)} anyway, and since it kills the constants, it makes sense to focus on {\ell^2_0(V)}. It is a vector space of dimension {n-1} where {n=|V|}.

One advantage is that the smallest eigenvalue is 0 if and only if the graph is disconnected: indeed, {\langle L f, f\rangle=0} is equivalent to {f} being constant on each connected component. We also gain better symmetry between {L} and the Laplacian of the graph complement, denoted {L'}. Indeed, since {L' f(v) = \sum_{u\colon u\not \sim v}(f(v)-f(u))}, it follows that {(L+L')f(v) = \sum_{u\colon u\ne v} (f(v)-f(u)) = n f(v)} for every {f\in \ell^2_0(V)}. So, the identity {L+L' = nI} holds on {\ell^2_0(V)} (it does not hold on {\ell^2(V)}). Hence the eigenvalues of {L'} are obtained by subtracting the eigenvalues of {L} from {n}. As a corollary, the largest eigenvalue of {L} is at most {n}, with equality if and only if the graph complement is disconnected. More precisely, the multiplicity of eigenvalue {n} is one less than the number of connected components of the graph complement.

Let {D} denote the diameter of the graph. Then the number of distinct Laplacian eigenvalues is at least {D}. Indeed, let {u, v} be two vertices at distance {D} from each other. Define {f_0(u) = 1} and {f_0=0} elsewhere. Also let {f_k=L^k f_0} for {k=1, 2, \dots}. Note that {f_k\in \ell_0^2(V)} for all {k\ge 1}. One can prove by induction that {f_k(w)=0} when the distance from {w} to {u} is greater than {k}, and {(-1)^k f_k(w) > 0} when the distance from {w} to {u} is equal to {k}. In particular, {f_k(v) = 0} when {k<D} and {f_D(v)\ne 0}. This shows that {f_D} is not a linear combination of {f_1, \dots, f_{D-1}}. Since {f_k = L^{k-1}f_1}, it follows that {L^{D-1}} is not a linear combination of {L^0, L^1, \dots, L^{D-2}}. Hence the minimal polynomial of {L} has degree at least {D}, which implies the claim.

Let’s consider a few examples of connected graphs.

3 vertices

There are two connected graphs: the 3-path (D=2) and the 3-cycle (D=1). In both cases we get D distinct eigenvalues. The spectra are [1, 3] and [3, 3], respectively.

4 vertices

  • One graph of diameter 3, the path. Its spectrum is {[2-\sqrt{2}, 2, 2+\sqrt{2}]}.
  • One graph of diameter 1, the complete graph. Its spectrum is {[4, 4, 4]}. This pattern continues for other complete graphs: since the complement is the empty graph ({n} components), all {n-1} eigenvalues are equal to {n}.
  • Four graphs of diameter 2, which are shown below, with each caption being the spectrum.
4-0
1, 1, 4
4-2
1, 3, 4
4-3
2, 2, 4
4-4
2, 4, 4

Remarks:

  • The graph [1, 3, 4] has more distinct eigenvalues than its diameter.
  • The graph [2, 2, 4] is regular (all vertices have the same degree).
  • The smallest eigenvalue of graphs [1, 1, 4] and [2, 2, 4] is multiple, due to the graphs having a large group of automorphisms (here rotations); applying some of these automorphisms to an eigenfunctions for the smallest eigenvalue yields another eigenfunction.
  • [1, 3, 4] and [2, 4, 4] also have automorphisms, but their automorphisms preserve the eigenfunction for the lowest eigenvalue, up to a constant factor.

5 vertices

  • One graph of diameter 4, the path. Its spectrum is related to the golden ratio: it consists of {(3\pm \sqrt{5})/2, (5\pm \sqrt{5})/2}.
  • One graph of diameter 1, the complete one: [5, 5, 5, 5]
  • Five graphs of diameter 3. All have connected complement, with the highest eigenvalue strictly between 4 and 5. None are regular. Each has 4 distinct eigenvalues.
  • 14 graphs of diameter 2. Some of these are noted below.

Two have connected complement, so their eigenvalues are less than 5 (spectrum shown on hover):

One has both integers and non-integers in its spectrum, the smallest such graph. Its eigenvalues are {3\pm \sqrt{2}, 3, 5}.

5-15
1.585786, 3, 4.414214, 5

Two have eigenvalues of multiplicity 3, indicating a high degree of symmetry (spectrum shown on hover).

Two have all eigenvalues integer and distinct:

 

The 5-cycle and the complete graph are the only regular graphs on 5 vertices.

6 vertices

This is where we first encounter isospectral graphs: the Laplacian spectrum cannot tell them apart.

Both of these have spectrum {3\pm \sqrt{5}, 2, 3, 3} but they are obviously non-isomorphic (consider the vertex degrees):

Both have these have spectrum {3\pm \sqrt{5}, 3, 3, 4} and are non-isomorphic.

Indeed, the second pair is obtained from the first by taking graph complement.

Also notable are regular graphs on 6 vertices, all of which have integer spectrum.

6-46
1, 1, 3, 3, 4
6-71
3, 3, 3, 3, 6
6-98
2, 3, 3, 5, 5
6-108
4, 4, 4, 6, 6
6-111
6, 6, 6, 6, 6

Here [3, 3, 3, 3, 6] (complete bipartite) and [2, 3, 3, 5, 5] (prism) are both regular of degree 3, but the spectrum allows us to tell them apart.

The prism is the smallest regular graph for which the first eigenvalue is a simple one. It has plenty of automorphisms, but the relevant eigenfunction (1 on one face of the prism, -1 on the other face) is compatible with all of them.

7 vertices

There are four regular graphs on 7 vertices. Two of them are by now familiar: 7-cycle and complete graph. Here are the other two, both regular of degree 4 but with different spectra.

7-720
3, 4, 4, 5, 5, 7
7-832
3.198, 3.198, 4.555, 4.555, 6.247, 6.247

There are lots of isospectral pairs of graphs on 7 vertices, so I will list only the isospectral triples, of which there are five.

Spectrum 0.676596, 2, 3, 3.642074, 5, 5.681331:

Spectrum 0.726927, 2, 3.140435, 4, 4, 6.132637:

Spectrum 0.867363, 3, 3, 3.859565, 5, 6.273073:

Spectrum 1.318669, 2, 3.357926, 4, 5, 6.323404:

All of the triples mentioned so far have connected complement: for example, taking the complement of the triple with the spectrum [0.676596, 2, 3, 3.642074, 5, 5.681331] turns it into the triple with the spectrum [1.318669, 2, 3.357926, 4, 5, 6.323404].

Last but not least, an isospectral triple with an integer spectrum: 3, 4, 4, 6, 6, 7. This one has no counterpart since the complement of each of these graphs is disconnected.

8 vertices

Regular graphs, excluding the cycle (spectrum 0.585786, 0.585786, 2, 2, 3.414214, 3.414214, 4) and the complete one.

Degree 3 regular:

8-4326
2, 2, 2, 4, 4, 4, 6
8-6409
0.763932, 2, 4, 4, 4, 4, 5.236068
8-6579
1.438447, 2.381966, 2.381966, 3, 4.618034, 4.618034
8-6716
1.267949, 2, 2.585786, 4, 4, 4.732051,
5.414214
8-8725
2, 2, 2.585786, 2.585786, 4, 5.414214,
5.414214

Degree 4 regular

8-4575
4, 4, 4, 4, 4, 4, 8
8-9570
2.763932, 4, 4, 4, 4, 6, 7.236068
8-10188
2.438447, 3.381966, 3.381966, 5, 5.618034, 5.618034, 6.561553
8-10202
2.585786, 3.267949, 4, 4, 5.414214, 6, 6.732051
8-10819
2.585786, 2.585786, 4, 5.414214, 5.414214, 6, 6
8-10888
2, 4, 4, 4, 6, 6, 6

Degree 5 regular

8-10481
4.381966, 4.381966, 5, 5, 6.618034, 6.618034, 8
8-10975
4, 4, 6, 6, 6, 6, 8
8-11082
4, 4.585786, 4.585786, 6, 6, 7.414214, 7.414214

Degree 6 regular

8-11112
6, 6, 6, 6, 8, 8, 8

Credits: the list of graphs by Brendan McKay and NetworkX library specifically the methods read_graph6 (to read the files provided by Prof. McKay), laplacian_spectrum, diameter, degree, and draw.

Moderatorship connections between Stack Exchange sites

Consider the graph in which the vertices are Stack Exchange sites, connected if two sites share a moderator. What does this graph look like? As being a moderator correlates with some level of expertise or at least interest in the topic, we can expect the structure of the graph to highlight topical connections between the sites.

Unsurprisingly, there is a dominant component (55 sites) centered at Stack Overflow. (Click the image for the larger version.)

SO_component
Stack Overflow component

Its radius is 6: every site can be joined to Stack Overflow by a path of length at most 6. The five sites at distance 6 from SO are Lifehacks, Martial Arts, Physical Fitness, Space Exploration, and Travel.

By the triangle inequality, the diameter of the SO component is at most 12. In fact it is exactly 12: it takes 12 steps to go from Space to either Fitness, Lifehacks, or Martial Arts.

The center of the SO component is not unique: Web Applications is another site from which every other one can be reached in 6 steps. And it has an advantage over SO in that only four sites in the component are at distance 6 from Web Apps. Naturally, these are the four sites that realize the diameter 12 of the component.

That said, Stack Overflow is the vertex of highest degree (8), meaning that Stack Overflow moderators also take part in moderating eight other sites.

What about other components? Excluding isolated vertices, we have the following picture of small components.

other_components
Other nontrivial components

The largest of these is the “language component”: English Language & Usage, English Language Learners, Japanese Language, Portuguese Language, and less logically, Sustainable Living. Other notable components are Unix (with bioinformatics thrown in) and Mathematics.


Source of the information: on the page listing moderators grouped by users I executed a JavaScript one-liner

JSON.stringify(Array.from(document.querySelectorAll('.mods-summary-list')).filter(e=>e.children.length>1).map(e=>Array.from(e.children).map(x=>x.hostname.split('.')[0])))

which gave a list of connections. The rest was done in Python:

import networkx as nx
from itertools import chain, combinations
connections = # copied JS output
edges = list(chain.from_iterable(combinations(c, 2) for c in connections))
G = nx.Graph()
G.add_edges_from(edges)
components = sorted(list(nx.connected_components(G)), key=len)
main_component = G.subgraph(components[-1])
pos = nx.kamada_kawai_layout(main_component)
nx.draw_networkx(main_component, pos=pos, node_size=100)

I used different layout algorithms for the dominant component and for the rest. The default “spring” layout makes the SO component too crowded, but is okay for small components:

other_components = G.subgraph(chain.from_iterable(components[:-1]))
pos = nx.spring_layout(other_components, k=0.25) 
nx.draw_networkx(other_components, pos=pos, node_size=100)

The rest was done by various functions of the NetworkX library such as

nx.degree(main_component)
nx.center(main_component)
nx.diameter(main_component)
nx.periphery(main_component)
nx.radius(main_component)
nx.shortest_path_length(main_component, source="stackoverflow")
nx.shortest_path_length(main_component, source="webapps")

The infinitely big picture: tanh-tanh scale

When plotting the familiar elementary functions like x2 or exp(x), we only see whatever part of the infinitely long curve fits in the plot window. What if we could see the entire curve at once?

The double-tanh scale can help with that. The function u = tanh(x) is a diffeomorphism of the real line onto the interval (-1, 1). Its inverse, arctanh or artanh or arth or {\tanh^{-1}x} or {\frac12 \log((1+x)/(1-x))}, whatever you prefer to call it, does the opposite. So, conjugating any function {f\colon \mathbb R\to \mathbb R} by the hyperbolic tangent produces a function {g\colon (-1, 1)\to (-1,1)} which we can plot in its entirety. Let’s try this.

Out of linear functions y = kx, only y=x and y=-x remain lines.

linear
Linear functions

The powers of x, from 1 to 4, look mostly familiar:

x1-4
x, x^2, x^3, x^4

Sine, cosine, and tangent functions are not periodic anymore:

sincostan
sin(x), cos(x), tan(x)

The exponential function looks concave instead of convex, although I don’t recommend trying to prove this by taking the second derivative of its tanh-conjugate.

exp
exp(x)

The Gaussian loses its bell-shaped appearance and becomes suspiciously similar to a semicircle.

gaussian
exp(-x^2/2)/sqrt(2pi)

This raises the question: which function does appear as a perfect semi-circle of radius 1 on the tanh-tanh scale? Turns out, it is {f(x) = \log|\coth(x/2)|}. Here it is shown in the normal coordinate system.

logcoth
log|coth(x/2)| without tanh conjugation

 

Graphs with an invertible incidence matrix

Graphs are often encoded by their adjacency matrix: a symmetric matrix where {1} in the entry {(i,j)} means there is an edge between vertices labeled {i} and {j}. Another useful encoding is the incidence matrix, in which rows correspond to edges and columns to vertices (or the other way around). Having {1} in the entry {(i,j)} means that {i}th edge is incident to {j}th vertex. Simply put, each row contains exactly two nonzero entries, which indicate the endpoints of an edge.

An incidence matrix is generally rectangular. It is the square matrix when the graph has as many edges as vertices. For example, the 4-cycle has incidence matrix

{M = \displaystyle \begin{pmatrix} 1 & 1 & 0 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 \end{pmatrix}}

(up to relabeling of vertices). This matrix is not invertible. Indeed, {M(1,-1,1,-1)^T=0}, which is a reflection of the fact that the graph is bipartite. Indeed, for any bipartite graph the {\pm 1} vector describing a 2-coloring of the vertices belongs to the kernel of the incidence matrix.

The incidence matrix of an odd cycle is invertible, however. What other such “invertible” graphs exist? Clearly, the disjoint union of “invertible” graphs is itself invertible, so we can focus on connected graphs.

There are no invertible graphs on 1 or 2 vertices. For 3 through 8 vertices, exhaustive search yields the following counts:

  • 1 graph on 3 vertices (3-cycle)
  • 1 graph on 4 vertices (3-cycle with an edge attached)
  • 4 graphs on 5 vertices
  • 8 graphs on 6 vertices
  • 23 graphs on 7 vertices
  • 55 graphs on 8 vertices

The numbers match the OEIS sequence A181688 but it’s not clear whether this is for real or a coincidence. The brute force search takes long for more than 8 vertices. It’s probably better to count such graphs by using their (folklore?) characterization as “trees planted on an odd cycle”, described by Chris Godsil on MathOverflow.

Some examples:

graph7_4

graph8_52

graph8_7

The examples were found and plotted by this Python script.

import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from itertools import combinations

def is_invertible(graph, n):
    matrix = []
    for i in range(n):
        row = [0]*n
        row[graph[i][0]] = 1
        row[graph[i][1]] = 1
        matrix.append(row)
    return abs(np.linalg.det(matrix)) > 0.5

n = 6   # number of vertices
graphs = combinations(combinations(range(n), 2), n)
inv = []
for g in graphs:
    if is_invertible(g, n):
        gr = nx.Graph(g)
        if nx.is_connected(gr) and not any([nx.is_isomorphic(gr, gr2) for gr2 in inv]):
            inv.append(gr)
            nx.draw_networkx(gr)
            plt.savefig("graph{}_{}.png".format(n, len(inv)))
            plt.clf()

print("There are {} connected invertible graphs with {} vertices".format(len(inv), n))

Random graphs with two-sided degree bounds

I wanted some random examples of graphs where every vertex has degree between two given parameters, minDegree and maxDegree. Like this one:

15 vertices, degree from 3 to 4
15 vertices, degree from 3 to 4

The approach I took was very simple (and not suitable for construction of very large or very regular graphs). Each edge appears with probability p. If the minimal degree is too small, this probability is multiplied by 1.1. If the maximal degree is too big, the probability is divided by 1.1. Either way, the process repeats until success.

g20-1-5
20 vertices, degree from 1 to 5

So far, this blog had too much Matlab/Scilab and not enough Python. I’ll try to restore the balance. Here, numpy generates random matrices and takes care of degree restrictions; networkx lays out the graph.

import numpy as np
import networkx as nx
import matplotlib.pyplot as plt

vertices = 15
minDegree = 3
maxDegree = 4
p = 0.5
success = False

while not success:
    a = (np.random.random((vertices, vertices)) < p).astype(int)
    a = np.maximum(a, np.matrix.transpose(a))
    np.fill_diagonal(a, 0)
    s = a.sum(axis=1)
    success = True
    if min(s) < minDegree:
        success = False
        p = p * 1.1
    if max(s) > maxDegree:
        success = False
        p = p / 1.1
g = nx.Graph(a)
nx.draw_networkx(g)
plt.show()

One more time:

g25-2-4
25 vertices, degree from 2 to 4