Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected static <V, E> void shortestPathLinhasL(Graph<V, E> g, V vOrig, V[] vertices,boolean[] visited, int[] pathKeys, double[] dist) {
- int vkey = g.getKey(vOrig);
- dist[vkey] = 0;
- while (vkey != -1) {
- vOrig = vertices[vkey];
- visited[vkey] = true;
- Set<String> linhaprev =new LinkedHashSet<String>();
- for (Edge<V, E> edge : g.outgoingEdges(vOrig)) {
- V vAdj = g.opposite(vOrig, edge);
- int vkeyAdj = g.getKey(vAdj);
- double tempo=0;
- Conexao x =(Conexao) edge.getElement();
- if(!linhaprev.isEmpty())
- {
- if(!(linhaprev.contains(x.getLinha().getCodigo())))
- {
- tempo=1;
- }
- else
- {
- tempo=0;
- }
- }
- linhaprev.add(x.getLinha().getCodigo());
- if (!visited[vkeyAdj] && dist[vkeyAdj] > dist[vkey] + tempo) {
- dist[vkeyAdj] = dist[vkey] + tempo;
- pathKeys[vkeyAdj] = vkey;
- }
- }
- double minDist = Double.MAX_VALUE;
- vkey = -1;
- for (int i = 0; i < g.numVertices(); i++) {
- if (!visited[i] && dist[i] < minDist) {
- minDist = dist[i];
- vkey = i;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement