Example #1
0
    _graph.add_edge('2','3',24)
    _graph.add_edge('6','3',18)
    _graph.add_edge('6','5',30)
    _graph.add_edge('6','7',5)
    _graph.add_edge('3','5',2)
    _graph.add_edge('3','t',19)
    _graph.add_edge('4','t',6)
    _graph.add_edge('4','3',6)
    _graph.add_edge('5','t',16)
    _graph.add_edge('5','4',11)
    _graph.add_edge('7','5',20)
    _graph.add_edge('7','t',44)

    print(_graph.graph)
    print('outnodes:')
    print(_graph.get_outnodes())
    print('shortest distance between s,t:',shortest_path(_graph,'s','t'))

    print('=============================================================')
    #edge_graph is type list
    _graph = EdgeGraph()
    print('EdgeGraph:')
    _graph.add_edge('s','2',9)
    _graph.add_edge('s','6',14)
    _graph.add_edge('s','7',15)
    _graph.add_edge('2','3',24)
    _graph.add_edge('6','3',18)
    _graph.add_edge('6','5',30)
    _graph.add_edge('6','7',5)
    _graph.add_edge('3','5',2)
    _graph.add_edge('3','t',19)