Ejemplo n.º 1
0
    def test_output_1(self):
        # The distance of the route A-D.
        graph_routesAC = Graph()
        graph_routesAC.build_graph(self.list_routes)
        graph_routesAC.path_list = graph_routesAC.build_path_list('A', 'C')
        value = graph_routesAC.find_path_size(["A", "B", "C"])

        self.assertEqual(9, value)
Ejemplo n.º 2
0
    def test_output_4(self):
        # The distance of the route A-E-B-C-D.
        graph_routesAD = Graph()
        graph_routesAD.build_graph(self.list_routes)
        graph_routesAD.path_list = graph_routesAD.build_path_list('A', 'D')
        value = graph_routesAD.find_path_size(["A", "E", "B", "C", "D"])

        self.assertEqual(22, value)
Ejemplo n.º 3
0
    def test_output_5(self):
        # The distance of the route A-E-D.
        graph_routesAD = Graph()
        graph_routesAD.build_graph(self.list_routes)
        graph_routesAD.path_list = graph_routesAD.build_path_list('A', 'D')
        value = graph_routesAD.find_path_size(["A", "E", "D"])

        self.assertEqual('NO SUCH ROUTE', value)
Ejemplo n.º 4
0
from lib.Graph import Graph

list_routes = input("Input the routes.(Example: 'AB5, BC4, CD8'):")
#list_routes = "AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7"

graph_routesAC = Graph()
graph_routesAC.build_graph(list_routes)
graph_routesAC.path_list = graph_routesAC.build_path_list('A', 'C')

graph_routesAD = Graph()
graph_routesAD.build_graph(list_routes)
graph_routesAD.path_list = graph_routesAC.build_path_list('A', 'D')

##############################################################################################################

size = graph_routesAC.find_path_size(["A", "B", "C"])
print('Output #1:', size)

##############################################################################################################

size = graph_routesAD.find_path_size(["A", "D"])
print('Output #2:', size)

##############################################################################################################

size = graph_routesAC.find_path_size(["A", "D", "C"])
print('Output #3:', size)

##############################################################################################################

size = graph_routesAD.find_path_size(["A", "E", "B", "C", "D"])