logo CodeStepByStep logo


Language/Type: C++ graphs collections
Related Links:
Author: Marty Stepp (on 2016/06/16)

Write a function named isConnected that accepts one parameter: a reference to a BasicGraph. Your function should return true if a path can be made from every vertex to any other vertex, or false if there is any vertex cannot be reached by a path from some other vertex. For example, the graph below is not connected because vertex H is not reachable from A. An empty graph is defined as being connected. (You may want to copy/paste your solution to the isReachable function from a previous exercise to help you solve this one.) You may assume that the parameter values passed are valid.

A --> B <-- C
|     |     ^
|     |     |
V     V     |
D <-- E --> F
|     ^     ^
|     |     |
V     |     |
G <-- H <-- I
Type your C++ solution code here:

This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.