October 2022
It’s hard to motivate the listing of all the groups of 4 countries that border one another. It doesn’t force the four-coloring of maps — these states need four colors even though they don’t have a K4 group:
It sort of relates to the quadripoint, which which may or may not exist at an intersection of Namibia, Zambia, Zimbabwe, and Botswana, but not really.
And there’s no geopolitical angle. Some K4 groups have conflict, some not.
So with little reason, here are the 12 groups of four countries that border one another according to World Bank data:
And the code that found them:
import json from itertools import combinations from collections import defaultdict # https://datacatalog.worldbank.org/search/dataset/0038272/World-Bank-Official-Boundaries # "World Boundaries GeoJSON - Very High Resolution" with open("WB_Boundaries_GeoJSON_highres/WB_Admin0_boundary_lines.geojson") as f: gj = json.load(f) assocs = { "Sint Maarten": "Netherlands", "Saint Martin": "France", # Cyprus associations are arbitrary and don't affect the output "Cyprus U.N. Buffer Zone": "Cyprus", "Cyprus No Mans Area": "Cyprus", "Dhekelia Sovereign Base Area": "United Kingdom", "Northern Cyprus": "Turkey", } def assoc(country): if country in assocs: return assocs[country] return country # Build adjacency list d = defaultdict(set) for feature in gj["features"]: i = assoc(feature["properties"]["adm0_left"]) j = assoc(feature["properties"]["adm0_right"]) if i == j: continue d[i].add(j) d[j].add(i) # Brute force K_4 subgraphs # Lots of sets to paper over my laziness subgraphs = set() for i in d: for j in combinations(d[i], 3): if j[0] in d[j[1]] and j[1] in d[j[2]] and j[2] in d[j[0]]: subgraphs.add(frozenset([i, j[0], j[1], j[2]])) for s in subgraphs: print(s)