Divide the vertices (arbitrarily) into V1 and V2 each of n
vertices. Respond to each question of the algorithm as follows:
- a) If the algorithm asks about u,v in V1 say "yes, (u,v) in E."
- b) If the algorithm asks about u,v in V2 say "yes, (u,v) in E."
- c) If the algorithm asks about u in V1 and v in V2 say "no, (u,v) not in E."
Notice that that algorithm cannot know G is not connected until it
has asked about every edge fitting under rule (c) above (since the
existence of any one of those edges in G would connect the graph).
The number of edges fitting rule (c) above is n2 and hence at least
n2 vertex pairs must be tested.