Suppose that we are given a graph, in which V is the set of vertices and Edge(x, y) is a predicate which tells us that vertices x and y are connected by an edge. Assume that there are no self-looping edges which connect a vertex to itself, and also assume that the graph is undirected, so that if Edge(x, y) is true, then Edge(y, x) must also be true. The graph will be used to represents a map, in which the vertices are cities and edges are highways between cities.
Suppose that we say that a city is a ”big city” if it’s connected to three or more other cities by a highway. Write a definition for a new predicate, Isolated(x), which tells us that x is not a big city, and there is no read that we can take from x which can lead us (directly or indirectly) to a big city. If we pass through five different cities until we eventually reach a big city, then x is not isolated, but if there’s no way to ever reach a big city, then it is isolated.
Note: it is legal, but not necessary, to define yet another predicate to help define Isolated(x). Hint: it may be necessary to use a recursive definition.
Zak P.
Just noticed a small error. In the last line of the Isolated() method, please change "return false;" to "return true;"-- my bad!11/19/20