-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
64 lines (50 loc) · 1.57 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
using namespace std;
struct edge;
//test
struct node {
char name;
int id;
bool visited;
edge *adjacentList;
};
struct edge {
node *from, *to;
edge *next, *previous;
};
int main(){
FILE *input, *output;
//Redirecting the standard input from to the input file
input = freopen("input.in","r",stdin);
//Checking if we have the input file
if (input == NULL){
perror("Problem to open the input file check if this file exists");
exit(-1);
}
//Reading the information about the network that will be processed
int n_nodes, n_edges, start_node;
scanf("%d %d %d", &n_nodes, &n_edges, &start_node);
printf("We have %d nodes with %d edges and we will start from %d edge.\n",n_nodes,n_edges,start_node);
//Creating the vector that will store the graph of the network
vector<node> nodes;
printf("Loading nodes...\n");
//Reading the node description from file
for (int i = 0; i < n_nodes; i++) {
node temp;
scanf("%d %s",&temp.id, &temp.name);
//Inserting the nodes into the vector of nodes
nodes.push_back(temp);
}
printf("We have %lu nodes to work.\n", nodes.size());
printf("Loading edges...\n");
for (int i = 0; i < n_edges; i++) {
int source, destination, weight;
scanf("%d %d %d", &source,&destination,&weight);
printf("%d %d %d\n", source,destination,weight);
//Creating the node
}
return 0;
}