Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct vertex
- {
- int x,y,cost;
- char name;
- struct vertex* edges[10];
- }node;
- int main()
- {
- char ch, file_name[25],data[10000];
- FILE *fp;
- //printf("Enter name of a input file\n");
- //gets(file_name);
- fp = fopen("data.txt", "r"); // read mode
- if (fp == NULL)
- {
- perror("Error while opening the file.\n");
- exit(EXIT_FAILURE);
- }
- int nodes_count,edges_count;
- char init,fin;
- fscanf(fp,"%i %i\n",&nodes_count,&edges_count);
- fscanf(fp,"%c %c\n",&init,&fin);
- //printf("%d %d %c %c",a,b,c,d);
- node* nodes[10];
- //creating nodes
- for(int i=0; i<nodes_count;i++)
- {
- nodes[i] = (node*)malloc(sizeof(node));
- int x,y;
- char n;
- fscanf(fp,"%d %d %c\n",&x,&y,&n);
- nodes[i]->name = n;
- nodes[i]->x = x;
- nodes[i]->y = y;
- }
- //printf("%d %d %c\n",nodes[7]->x,nodes[7]->y,nodes[7]->name);
- int decode(char n)
- {
- for(int i = 0; i < nodes_count;i++)
- if(nodes[i]->name == n)
- return i;
- }
- //creating edges
- for(int i=0; i < edges; i++)
- {
- int index=0,cost;
- char from,to;
- }
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement