Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. private static void Get_dMins(StringTokenizer st, BufferedReader br) throws IOException {
  2.         potentials = new LinkedList<>();
  3.         int x, y, phi;
  4.         for (int i = 0; i < P; i++) {
  5.             st = new StringTokenizer(br.readLine(), " ");
  6.             x = Integer.parseInt(st.nextToken())-1;
  7.             y = Integer.parseInt(st.nextToken())-1;
  8.             phi = Integer.parseInt(st.nextToken());
  9.             potentials.add(graph[x][y]);
  10.            
  11.             graph[x][y].d_min = 0;
  12.             graph[x][y].phi_min = phi;
  13.         }        
  14.         Collections.sort(potentials, new VertexComparator());
  15.                
  16.     }
  17.  
  18. private static void FillInVerticesNumbers() {
  19.         while(!potentials.isEmpty()){
  20.             Vertex act = potentials.pop();
  21.             int phi = act.phi_min;
  22.             int d = act.d_min +1;
  23.             for(Edge e : act.edges){
  24.                Vertex v = e.v1;
  25.                if(v.equals(act)){
  26.                    v = e.v2;
  27.                }
  28.                 if(v.d_min>d){
  29.                     v.phi_min = phi;
  30.                     v.d_min = d;
  31.                     potentials.add(v);
  32.                 }                
  33.             }            
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement