top of page
Writer's picturemasonstooksbury

The Pig That Wants to Be Eaten - Chapter Reference Graph

Updated: Sep 23, 2023


This graph is nuts, so let me try and explain what you're looking at.

Recently, I've been reading The Pig That Wants to Be Eaten by Julian Baggini. It's a book with 100 philosophical thought experiments to mull over. It's nice because each experiment is only a page or two in length so it's very easy to read a couple to think on for the day.

At the end of each chapter, the author references four other chapters "to be suggestive, not scientific. Sometimes the connections between scenarios will be obvious. [...] the link itself is a means of making you look at the problem in a new light." I was curious of these references, and had three questions come to mind:

[1] Are chapter references evenly distributed? (i.e. are all chapters referenced the same amount of times? Or is there a large disparity?)

[2] Which chapter is referenced the least?

[3] Which chapter is referenced the most?

To accomplish this, I tried to use some various graph database technologies but ultimately just decided to hamfist it with Python; utilizing the PySimpleAutomata module. I started by writing down all the chapter names as well as the four chapters it referenced. From there I created a quick Python script to restructure the data to be used by the PySimpleAutomata module to create the above graph. I also had it figure out which chapters were referenced the most and the least and found out that:


[2] Chapters 33, 67, and 75 were not referenced by any other chapter

[3] Chapter 91 was referenced by 10 other chapters


To find out the answer to my first question, I needed to put the data into a different graph. There's plenty of ways to plot distribution, but I decided to go with using a Matplotlib scatter plot since I figured it would be a little easier to see rather than having something like a bar graph with 100 tiny bars on it. For that, I simply needed to restructure my data a little to put the chapter IDs in one array and the associated references to that chapter in another (but keeping them at the same index, so they match). After some visual tweaking I ended up with this:



All in all it was a fun couple of hours and I got to learn more about PySimpleAutomata as well as get more exposure to Matplotlib.

Tags:

16 views

Recent Posts

See All
bottom of page