logo CodeStepByStep logo

isConnected

Language/Type: C++ graphs collections
Related Links:

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
Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.