# Lab 11: Graph Search - Bus Stops ## Graph Search Basics The purpose of this lab is to give you practice implementing graph data structures and basic graph traversal and reachability queries. You are building an app for a newly created bus system connecting Harrisonburg to Charlottesville. There are many different bus routes each of which travels between named stops along its route. Not all of the bus routes cross each other, so it is possible that there are some pairs of stops where there is no way of getting on a bus at the first stop and making changes to get to the final stop. Your task is to implement a graph search function that can determine a sequence of stops a user can use to get from a starting stop to an ending stop, or to tell the user that there is no bus route possible between those two stops. ## Input The bus route segments are described as single stretches of road between two consecutive stops. All such pairs will be described in one direction, but all bus routes are bidirectional, since buses travel in both directions along each route. The first line of input has an integer n that is the number of road segments between consecutive stops. The next n lines of input describe the consecutive stops, each of which is named by a string of alphabetical characters with no spaces. The line will contain both of the stops of the segment, separated by a space. The final line of input is the query, which is two stop names separated by a space. ## Output Give a sequence of stop names starting at the starting stop of the query and ending at the ending stop separated by spaces (if one exists), or output "no route possible" if none is found.
| Sample Input | Sample Output |
2 Hburg JMU Charlottesville JMU Hburg Charlottesville |
Hburg JMU Charlottesville |
4 Hburg JMU JMU Upark Upark Hburg CVO UVA Hburg UVA |
no route possible |