forked from logicchains/LPATHBench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphgen.cpp
More file actions
45 lines (35 loc) · 822 Bytes
/
graphgen.cpp
File metadata and controls
45 lines (35 loc) · 822 Bytes
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
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;
struct route{
int dest, cost;
};
struct node {
vector<route> neighbours;
};
int main( int argc , char * argv [] ){
int verticies = 20;
if( argc == 2 ){
verticies = atoi( argv[1] );
}
int maxDist = 1000;
vector< node > graph;
graph.reserve( verticies );
//generate a fully connected graph with random weights
for( int i=0; i < verticies ; i ++ ){
node n;
for( int j=0; j < verticies ; j ++ ){
n.neighbours.push_back( { j , rand()%maxDist } );
}
graph.push_back( n );
}
cout<<graph.size()<<endl;
for( size_t i=0; i < graph.size() ; i ++ ){
const auto &n = graph[i];
for( const auto &r : n.neighbours ){
cout<<i<<" "<<r.dest<<" "<<r.cost<<endl;
}
}
return 0;
}