예제 #1
0
  public static void main(String args[]) throws Exception {
    HashMap<Integer, Integer> fileToGraphVIDMap = new HashMap<Integer, Integer>();
    MyGraph<Coordinate, Street> g =
        GraphFactory.loadGraph("./graphs/distanceedjohnDijkstra.txt", true, fileToGraphVIDMap);

    g.removeEdge(7);
    g.removeEdge(8);
    g.removeEdge(14);
    printList(doTopologicalSort(g));

    MyDijkstra<Coordinate, Street> dijkstra = new MyDijkstra<Coordinate, Street>();
    dijkstra.setGraph(g);
    dijkstra.setStart(5);
    dijkstra.setWeighing(new MyWeighing(g));

    dijkstra.computeShortestPath();

    GuiGraphDriver gui = new GuiGraphDriver(g);

    List<Integer> path = dijkstra.getPath(8);
    gui.addPath(path, Color.yellow);
    printList(path);

    g.removeEdge(dijkstra.getConnectingEID(2));
    dijkstra.computeShortestPath();

    path = dijkstra.getPath(8);
    gui.addPath(path, Color.cyan);
    printList(path);

    /*        g.removeEdge(dijkstra.getConnectingEID(7));
    dijkstra.computeShortestPath();
    printList(dijkstra.getPath(7));
    */

  }