100
Dispatch → Account → Science
Six Degrees of NationStates: A Study
Edit 30/05/2025: Uploaded code to
GitHub Introduction
From
Wikipedia:
"Six degrees of separation is the idea that all people are six or fewer social connections away from each other. As a result, a chain of "friend of a friend" statements can be made to connect any two people in a maximum of six steps."
This idea is not a scientific theory; that is, it has never been actually proven, as it is something that's very difficult to prove. After all, how can you obtain data on everyone's social connections? Social media networks, perhaps? However, those do not always reflect true social connections; people typically have many more connections on social networks than they have IRL. And most of those connections are not actually meaningful - while online friendships do exist, a lot of social media users follow each other simply to increase their follower count, such that the people they actually interact with are a fraction of their "connections". Many have said that social media has diluted the meaning of the term "friend".
On the other hand, some real-life connections are not always reflected on social media. How many of you follow your grand-parents on Instagram?
Nevertheless, we can take away something from this idea: it's a small world, and most of us are closer than we think. The idea that, through six social connections, six "friends of a friend", we could contact any famous person, or indeed any human in the world, seems mind-boggling, but while it's not proven that six is the exact number, it's not far from reality.
And this closeness does not only work for humans - this is an idea that applies to any large network. For example, you can go from almost any given article on Wikipedia to a completely unrelated one with just eight clicks or less,
which was the topic of a very interesting video I watched recently, and which inspired this experiment.
But what about NationStates? If you picked two of the world's regions at random, and went from one to the other by only traversing their embassy lists, how short could the path between them be? The answer is: it's shorter than you think.
The Experiment
Let's take two
completely random regions as an example. The Communist Bloc, the largest leftist region on NationStates, and Fifth Empire, the largest fascist region on NationStates.
These two regions' political stances are completely opposite to each other, and the nature of Fifth Empire's ideology makes it so that their region is (rightfully) shunned from most of the NationStates world. As such, one would think you would need to traverse quite a few embassies to get from one to the other, right? How many connections do you think it takes?
Three. The shortest path from TCB to FE is three connections. Don't believe me? Here's the demonstration:
The Communist Bloc
has an embassy with Anarchy,
which has an embassy with Regionless,
which, in turn, has an embassy with Fifth Empire.
I can already hear your response:
"But Regionless is an embassy collector! Of course they connect completely different regions together!"
So let's take a quick pause to talk about embassy collectors. They're kind of an outlier (alongside trophy networks, which we will discuss later), in that there's nothing equivalent in our human network; they're like the "popular person", except they're really popular, because where have you seen someone with 1500 friends in real life? And I'm talking friends, not social media followers.
But at the same time, they're not popular at all; embassy collectors are often seen as a problematic nuisance (due to their refusal to not establish connections with regions that have a bad reputation, and their frequent spamming of embassy requests), so many regions, especially major ones, tend to avoid them and recommend their embassy partners do the same. However, it is not rare to find a major region having an embassy with some small region that has an embassy collector. And this case could just be an outlier, after all.
It is not an outlier. There are 20,816,478 pairs of regions (as of April 2nd, 05:40 AM UTC) that can be traversed using only 3 connections. That's 20 million.
Out of the 165 million total pairs of regions you can make, that's a pretty sizable amount.
The Data
But how does one find the shortest path from one of these regions to another? And where does the 20 million figure come from? I will share my process here, with Python code in spoilers, though it's not required to understand it in order to follow along. It may be useful if you want to replicate the results, or calculate the shortest path for any two regions of your choosing.
I will be using the Python library
NetworkX for all of this.
So, first of all, we need to download the regional data dump from NationStates, and uncompress it. The resulting file is around 50 megabytes at the date of writing.
import xml.etree.ElementTree as ET
import networkx as nx
def parseRegionData(filename: str):
tree = ET.parse(filename)
root = tree.getroot()
regions = []
embassies = []
for region in root.findall("./REGION"):
name = region.find("NAME")
embassy_list = []
for child in region.find("EMBASSIES"):
if("type" in child.attrib.keys()):
if(child.attrib["type"] in ["denied", "requested", "rejected", "pending", "invited"]):
print(f"Embassy between {name.text} and {child.text} skipped because it's {child.attrib["type"]}.")
continue
embassy_list.append(child.text)
regions.append(name.text)
embassies.append((name.text, embassy_list))
return (regions, embassies)
def generateEmbassyGraph(regions, embassies) -> nx.Graph:
graph = nx.Graph()
graph.add_nodes_from(regions)
for region in embassies:
name = region[0]
embassy_list = region[1]
for embassy in embassy_list:
graph.add_edge(name, embassy)
print(f"Number of regions: {graph.number_of_nodes()}")
print(f"Number of embassies: {graph.number_of_edges()}")
return graph
(regions, embassies) = parseRegionData("regions.xml")
graph = generateEmbassyGraph(regions, embassies)
nx.write_gml(graph, "network.gml")
So, now that we have constructed a graph between all regions on NationStates, finding the shortest path between two regions is a piece of cake!
import networkx as nx
graph = nx.read_gml("network.gml")
source = input("Enter the source region: ")
target = input("Enter the target region: ")
path = nx.shortest_path(graph, source, target)
print(path)
And another thing that can be done with the graph is... visualizing it!
Visualizing the Graph

We can notice three things right away - the unconnected ring around the edge (which is simply all the regions that do not have any embassies), the big "blob" on the bottom left, and a few smaller clusters.
The majority of NationStates' embassy network is actually concentrated on the "big blob"; the smaller clusters you can see are generally trophy networks. Here are a few examples:


As for embassy collectors, they are actually not located within the small clusters, but the big blob. That is because, unlike trophy "collectors", whose embassies are locked down and isolated regions, embassy collectors' embassy regions are typically connected to the rest of the world in some way.
Crunching Data: So, How Many Degrees of Separation?
What if we just took every single pair of regions (excluding isolated ones) and calculated the length of the shortest path between them?
What's the highest we can get? How many connections do you need to make sure you can get from any given region to any other one?
Well, you see... while most pairs of regions can be connected with a small number of embassies, there are a few outliers.
As of writing, it takes 1777 connections! to get from either of Banana or Boscorum to Rashida Ann Tlaib.
When the embassy between Banana and Accommodators closes, it will be 1778 from Banana to Rashida Ann Tlaib.
However, this is clearly intentional, as it is a long line of regions that have no embassies with anyone except the previous and next region in the chain. As I said, it is an outlier.
The vast majority of regions can be connected with less than 8 embassies.
Here's the code to crunch the numbers:
import networkx as nx
import time, itertools
def allShortestPaths(gml, output):
graph = nx.read_gml(gml)
all_nodes = list(graph)
processed = 0
total_to_process = len(all_nodes)
start = time.time()
with open(output, "w+") as output_file:
for batch in itertools.batched(all_nodes, 1000):
for source in batch:
for target, length in nx.single_source_shortest_path_length(graph, source).items():
output_file.write(f"[{length}] | {source} - {target}\n")
processed += len(batch)
current = time.time()
print(f"{processed} regions computed out of {total_to_process} in {current-start} seconds")
estimated_time_left = ((total_to_process-processed)/processed) * (current-start)
print(f"Estimated time left: {estimated_time_left} seconds")
allShortestPaths("network.gml", "paths.txt")
WARNING: This code will take a while to run, and the output file will be LARGE - for me, it took around 15 minutes, and the output file was around 13GB, with 330 million lines of text.
Since the pairs are duplicated (both "Region A - Region B" and "Region B - Region A" appear), out of the 330 million lines, there are 165 million pairs.
Filtering through the file for lengths 1 to 10, we get the following results:

As you can see, 8 connections can cover almost any pair - and more than half can be connected with just four.
Conclusions
This was a really fun little afternoon project for me. If you found it interesting, please do leave an upvote, and if you have any questions, send me a telegram.
Thank you to
The Western European Commonwealth for posting the spark of inspiration that led to this!
