1 · Resolve
Each box of text goes to the Wikidata search API and comes back as a QID, so nothing guesses at identifiers.
2 · Expand
One SPARQL query per endpoint pulls every item it links to or from, in both directions, with the property that joins them.
3 · Intersect
Bidirectional search: the two neighbour sets are intersected in the browser. Anything in both is a two-degree bridge.
4 · Rank
Bridges are scored by how specific the connecting property is, so “married to” beats “country of citizenship.”
It takes two queries rather than six, because bidirectional intersection means a path of length 2 costs two expansions instead of walking the graph outward one hop at a time.