Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "PriQ.h"
- int main (int argc, char *argv[]){
- int n, i = 0;
- Edge temp;
- if(scanf("%d", &n)==1){
- Graph g = newGraph(n);
- float *x = malloc(sizeof(*x)*n);
- int *v = malloc(sizeof(*v)*n);
- int *w = malloc(sizeof(*w)*n);
- if(x==NULL || v==NULL || w==NULL){
- fprintf(stderr, "main: out of memory\n");
- exit(EXIT_FAILURE);
- }
- for(i=0; i<n; i++){
- x[i]=0;
- v[i]=0;
- w[i]=0;
- }
- i = 0;
- while(scanf("%d-%d:%f", &v[i], &w[i], &x[i])==3){
- temp = newE(v[i], w[i], x[i]);
- insertE(g, temp);
- i++;
- }
- showGraph(g);
- //PRIORITY QUEUE STUFF
- PriQ pq = createPQ(n);
- for(i=0; i<n; i++){
- temp = newE(v[i], w[i], x[i]);
- insertPQ(pq, temp);
- }
- for(i=0; i<n; i++){
- temp = delMaxPQ(pq);
- showE(temp);
- }
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment