-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproj-readInData.cpp
More file actions
56 lines (42 loc) · 1.42 KB
/
proj-readInData.cpp
File metadata and controls
56 lines (42 loc) · 1.42 KB
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
//Loads an edgelist and turns it into a binary graph file
// First argument is the name of the input data
// Second argument is the name of the desired output
// e.g., "proj-readInData.exe test.txt outputGraph.graph"
#include "Snap.h"
#include <time.h>
int main(int argc, char* argv[]) {
time_t beginTime = time(NULL); //for timing reads
//Load data from edge list
printf("Loading data from: %s \n", argv[1]);
PNGraph G = TSnap::LoadEdgeList<PNGraph>(argv[1],0,1);
//print time it took to read the file
time_t endTime = time(NULL);
double seconds = difftime(endTime,beginTime);
printf("Read file in %.f seconds \n", seconds);
//print basic diagnostics
printf("G->GetNodes() = %d, G->GetEdges() = %d\n", G->GetNodes(), G->GetEdges());
//determine correct name to output file to
char *FName;
if(argc < 3)
{
FName = "output.graph";
}
else
{
FName = argv[2];
}
//reset timer
beginTime = time(NULL);
//output file
{ TFOut FOut(FName); G->Save(FOut); }
endTime = time(NULL);
seconds = difftime(endTime,beginTime);
printf("Wrote file in %.f seconds \n", seconds);
// //load binary and test
// TFIn FIn("test.graph");
// PNGraph G2 = TNGraph::Load(FIn);
//printf("G->GetNodes() = %d, G->GetEdges() = %d\n", G->GetNodes(), G->GetEdges());
// save and load from a text file
//TSnap::SaveEdgeList(G2, "test.txt", "Save as tab-separated list of edges");
return (0);
}