GraphController gc = Lookup.getDefault().lookup(GraphController.class);
AbstractShortestPathAlgorithm algorithm;
if (gc.getModel().getGraphVisible() instanceof DirectedGraph) {
DirectedGraph graph = (DirectedGraph) gc.getModel().getGraphVisible();
algorithm = new BellmanFordShortestPathAlgorithm(graph, n);
algorithm.compute();
} else {
Graph graph = gc.getModel().getGraphVisible();
algorithm = new DijkstraShortestPathAlgorithm(graph, n);
algorithm.compute();