Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module algo();
- input clk_50;
- reg [100:0] cost [0:49][0:49];
- parameter INF = 999;
- reg [5:0] n;
- function getMin;
- integer key 0 ;
- integer i 0;
- begin
- for (i 0;i<n;i i+1)
- if(!visited[i] && dist [i] < min)
- begin
- min <= dist[i];
- key <= i;
- end
- end
- endfunction
- /*function display;
- integer k 0;
- integer par;
- */
- function dijsktra;
- reg [49:0] par [0:49];
- reg [49:0] dist [0:49];
- reg visited [0:99] = 0;
- dist[src] = 0;
- par[src] = -1;
- integer k 0;
- integer v 0;
- begin
- for (k 0; k < n- 1; k k+1)
- assign u = getMin(dist,visited);
- for (v 0; v < n; v v+1)
- if(!visited[v] && (dist[u] + cost[u][v] < dist[v] && cost[u][v]! = 999 )
- begin
- par[v] = u;
- dist[v] = dist[u] + cost[u][v];
- end
- end
- endfunction
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement