Yes it is not to hard to code if you have one thing: A connection graph of all counties. You can probibly extract one automaticly from osm data but i suspect writing the code that does that is time consumption
If i get a graph with all connection i can code a checker
The table looks like this is 2,3,4 is all connected to each other and 1 only to 2. You only need one connection per pair it is not necessary to say 2->3 and 3->2
county={
[1]="County1",
[2]="County2",
[3]="County3",
[4]="County4"
}
connection={
[1]={2},
[2]={3,4}
[3]={4}
}