An edgy intro to graphs of interpersonal relationships

Piotr Migdał
5 min readMar 2, 2019

(CW: human sexuality, maths, LaTeX, spoilers for the Game of Thrones; based on a talk I gave with Michał Kaftanowicz)

xkcd 403: Convincing Pickup Lines (CC BY-NC) from “a webcomic of romance, sarcasm, math, and language”.

Everyone chuckles and you are left out. And it is not the only xkcd strip on the intersection of sex and graph theory (some are even more niche, dedicated to heavy math users, e.g. Hamiltonian).

So, what is a graph (also known as a network)? In short, it is a collection of dots (representing entities) with some of them being connected by lines. Or, as a diagram is worth a thousand equations:

For a longer introduction, there is a beautiful introduction to graph theory in D3.js.

OK, so how does it relate to social relationships? Well, we can turn to the den of notworking, Facebook. Each node is a person, each link means that those people are Facebook friends. It excludes the main person, as they would be connected to everyone (giving no additional information, and a lot of clutter).

A network of Facebook friends from Data Science of the Facebook World by Stephen Wolfram

We can notice that nodes tend to cluster. Two people who have mutual friends are more likely to be friends. Maybe they have similar interests, or they met each other through the same groups and events. And here is mine:

A graph of my Facebook friends from 2014, in Gephi. On the left its raw form, with blue for male and pink for female friends. On the right — automatic community detection (based only on links), plus manual descriptions I added afterward.

Various things start during high school (OK, for brainy kids they often start later; discussed and hopefully remedied in my Dating for Nerds).

From Bearman, Moody & Stovel, Chains of affection: The structure of adolescent romantic and sexual networks (2004).

Here is an opposite pattern — links are not clustered (in fact, they tend to avoid each other). The authors were surprised by the low number of cycles (lines in a circle). One may guess that a cultural trope of “don’t date your friend’s ex” plays a role (and other things related to jealousy and bad breakups).

In networking, we often talk about the six degrees of separation — i.e. that within 6 handshakes most people are connected to each other (though now it may be closer to three and a half degrees of separation by Facebook). For the sake of STI safety, we can talk also about other… shakes.

Instead of relationships, we can look at acts. To get into juicy topics, let’s look at pop culture — The Game of Thrones:

The Game of Thrones Sex Infographic by Tim Jacobsen from Cool Material; this chart is so old, that either you already know it all, or are not interested.

Confused by a complex set of ties? So is benzene:

“They say that for people 3 bonded together is already too much”. — (posted with permission)

Yet, polyamory can be represented with a multigraph (pun totally indented):

Polycule from Kimchi Cuddles webcomic (see also its previous versions)

Do you think it is complicated? At least all these relationships are symmetric. Which may be not the general case:

The “to love is to suffer” scene from Love and Death (1975) by Woody Allen

Lost? Well, not anymore, here is a (directed) (multi)graph:

The love and death crush graph by Michał Kaftanowicz (2014); see also a TikZ/LaTeX diagram


During the next party, draw a diagram of the participants. (Try ignoring questions whether you are high or drunk.)

Who is (or were) in a relationship? Any married couples? Or one-sided crushes? Are there any relatives? Colleagues? It is totally up to you what do you decide to include!

Alternatively, draw (if you are traditional) a family tree, or (if not so much) non-monogamous relationship chart. If you are a mathematician (let’s make it clear: you aren’t here to learn about graphs), you can draw your doctoral ancestors.

Or, from your favorite game, movie or TV series. There is a lot of drama there. Hopefully much more drama than in your personal life.

Links and references

For drawing diagrams, any tool is a good tool. It can be a pen & pencil, or the venerable MS Paint. Some other resources that may be useful:

It used to be easy to download one’s graph of Facebook friends. Now it is much harder, and you need to resort to scraping, see: Tutorial: Plotting your Facebook friend network using NetworkX and python-louvain by Eliot Andres.

For a comprehensive, yet simple, introduction graphs for social networks I recommend a book Network Science by Albert-László Barabási, one of the key figures in complex systems. We just started with nodes & edges, and there is so much more interesting content.

If you are into the sociology of relationships —see Sex by Numbers: What Statistics Can Tell Us About Sexual Behaviour by David Spiegelhalter. While you won’t see many graphs (as networks; there are plenty of other charts), it does a stellar job of comparing statistics of various quality.

I have a soft spot for interactive graph viz in D3.js, see my projects:

Disclaimers, thanks, and adverts

All graphics belong to their creators. Do maths at your own risk.

While I know that sex does not sell, at least — not anymore (see: Teenagers are better behaved and less hedonistic nowadays — The Economist), I give it a try.

Readership of my blog,



Piotr Migdał

PhD in quantum physics, deep learning & data viz specialist. Founder at Quantum Flytrap. /