4 if (
this != &TimeNet) {
16 for (node = 0; node < NIdV.
Len(); node++) {
19 for (node = 0; node < NIdV.
Len(); node++) {
20 NI =
GetNI(NIdV[node]);
21 const int SrcNId = NI.GetId();
22 for (edge = 0; edge < NI.GetOutDeg(); edge++) {
23 const int OutNId = NI.GetOutNId(edge);
24 if (NewNet.
IsNode(OutNId)) {
25 NewNet.
AddEdge(SrcNId, OutNId); }
35 for (
int i = 0; i < NIdV.
Len(); i++) {
36 const int Src = NIdV[i];
37 const TTimeNet::TNodeI NI =
GetNI(Src);
38 const TSecTm SrcTm = NI.GetDat();
39 if (! OutNet->IsNode(Src)) { OutNet->AddNode(Src, SrcTm); }
40 for (
int e = 0; e < NI.GetOutDeg(); e++) {
41 if (! OutNet->IsNode(NI.GetOutNId(e))) { OutNet->AddNode(NI.GetOutNId(e), SrcTm); }
42 OutNet->AddEdge(Src, NI.GetOutNId(e), -1, SrcTm);
50 for (TNodeI NodeI =
BegNI(); NodeI <
EndNI(); NodeI++) {
54 for (
int i = 0; i < TmToNIdV.
Len(); i++) {
55 NIdV.
Add(TmToNIdV[i].Dat); }
61 for (TNodeI NodeI =
BegNI(); NodeI <
EndNI(); NodeI++) {
62 const int TmId = NodeI().Round(TmUnit);
63 if (! TmIdToNIdVH.
IsKey(TmId)) TmIdToNIdVH.
AddKey(TmId);
64 TmIdToNIdVH.
GetDat(TmId).
Add(NodeI.GetId());
69 TmBucketV.
Gen(TmIdNIdVV.
Len());
70 for (
int i = 0; i < TmIdNIdVV.
Len(); i++) {
72 Bucket.
BegTm = TmIdNIdVV[i].Val1;
73 Bucket.
NIdV = TmIdNIdVV[i].Val2;
80 TmBucketV.
Gen(NIdV.
Len() / NodesPerBucket + 1, 0);
81 for (
int i = 0; i < NIdV.
Len(); i++) {
82 const int b = i/NodesPerBucket;
84 TmBucketV[b].NIdV.
Add(NIdV[i]);
94 for (
int t = 0; t < TmBucketV.
Len(); t++) {
95 NodeIdV.
AddV(TmBucketV[t].NIdV);
96 printf(
"\n=== %d/%d] %s (%d nodes)\n", t+1, TmBucketV.
Len(),
97 TmBucketV[t].BegTm.GetStr().CStr(), NodeIdV.
Len()); ExeTm.
Tick();
98 if (TmBucketV[t].BegTm < StartTm)
continue;
101 GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
107 const TSecTm& StartTm,
const int& NDiamRuns,
const bool& OnlyWcc,
const bool& AlsoRewire)
const {
115 for (
int t = 0; t < TmBucketV.
Len(); t++) {
116 NodeIdV.
AddV(TmBucketV[t].NIdV);
117 printf(
"\n*** %d/%d] at %s (%d nodes)\n", t+1, TmBucketV.
Len(),
118 TmBucketV[t].BegTm.GetStr(TmUnit).CStr(), NodeIdV.
Len()); ExeTm.
Tick();
119 if (TmBucketV[t].BegTm < StartTm)
continue;
123 for (
int r = 0; r < NDiamRuns; r++) {
124 printf(
"%d...", r+1); Run1Tm.
Tick();
126 Mom.
Add(EffDiam); printf(
"[%s]\r", Run1Tm.
GetTmStr());
132 printf(
" [%s] \n", ExeTm.
GetTmStr()); }
140 for (
int r = 0; r < NDiamRuns; r++) {
141 printf(
" diam run %d...", r+1); Run1Tm.
Tick();
143 Mom.Add(EffDiam); printf(
" current run [%s]\n", Run1Tm.
GetTmStr());
146 RwTmDiamV.
Add(
TFltTr((
int)TmBucketV[t].BegTm.GetInUnits(TmUnit), Mom.GetMean(), Mom.GetSDev()));
149 printf(
"done with diameter. Total time [%s] \n", ExeTm.
GetTmStr());
155 if (! RwTmDiamV.
Empty()) { GnuPlot.
AddErrBar(RwTmDiamV,
"Rewired",
"");}
158 GnuPlot.
SetXYLabel(
"NODES", WccStr+
"Effective Diameter");
160 if (! RwNdsDiamV.
Empty()) { GnuPlot.
AddErrBar(RwNdsDiamV,
"Rewired",
"");}
170 const TSecTm& DelPreTmEdges,
const TSecTm& PostTmDiam)
const {
171 printf(
"\nGrowth over time: degree distribution, Growth Power Law, Diameter.\n %s group by %s.\n",
173 printf(
" Delete out-edges of pre time %s nodes.\n Take subgraph of post year %s subgraph.\n\n",
175 const int NDiamRuns = 10;
176 const int NSamples = 100;
180 if (DelPreTmEdges.
IsDef()) {
181 int NDelNodes = 0, NDelEdges = 0;
182 printf(
"Deleting pre-%s node out-links\n", DelPreTmEdges.
GetStr().
CStr());
183 for (TNodeI NodeI =
BegNI(); NodeI <
EndNI(); NodeI++) {
184 if (NodeI() < DelPreTmEdges) {
185 const int NodeId = NodeI.GetId();
186 for (
int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
187 FullGraph->
DelEdge(NodeId, NodeI.GetOutNId(edge)); }
188 NDelEdges += NodeI.GetOutDeg(); NDelNodes++;
191 printf(
" Deleted %d nodes out-edges (%d edges total).\n", NDelNodes, NDelEdges);
195 TFltV PreDiamSDev, PreEffDiamSDev, WccDiamSDev, WccEffDiamSDev;
200 for (
int t = 0; t < TmBucketV.
Len(); t++) {
201 printf(
"\nGraph: %s (%d / %d) [%s]\n", TmBucketV[t].BegTm.GetTmStr().CStr(),
204 NodeIdV.
AddV(TmBucketV[t].NIdV);
205 if (TmBucketV[t].BegTm < PostTmDiam) {
continue; }
208 TIntV PostYearNIdV, WccPostYearNIdV;
210 if (
GetNDat(NI.GetId()) >= PostTmDiam) {
211 PostYearNIdV.
Add(NI.GetId());
212 if (WccGraph->
IsNode(NI.GetId())) { WccPostYearNIdV.
Add(NI.GetId()); }
215 TMom PreDiamMom, PreEffDiamMom, WccDiamMom, WccEffDiamMom;
217 int FullDiam;
double EffDiam;
218 for (
int r = 0; r < NDiamRuns; r++) {
219 if (! PostYearNIdV.
Empty()) {
221 PreDiamMom.
Add(FullDiam); PreEffDiamMom.
Add(EffDiam);
223 if (! WccPostYearNIdV.
Empty()) {
225 WccDiamMom.
Add(FullDiam); WccEffDiamMom.
Add(EffDiam);
227 printf(
" diam: %d [%s] \r", r+1, ExeTm.
GetTmStr()); ExeTm.
Tick();
229 PreDiamMom.
Def(); PreEffDiamMom.
Def();
230 WccDiamMom.
Def(); WccEffDiamMom.
Def();
232 PGStat GraphStatPt = GrowthStat->Add(TmBucketV[t].BegTm);
233 TGStat& GS = *GraphStatPt;
244 {
TFOut FOut(
"growth."+FNmPref+
".gStatVec"); GrowthStat->
Save(FOut); }
245 GrowthStat->SaveTxt(FNmPref,
TStr::Fmt(
"%s. MISSING PAST DIAMETER\nDelPreEdges\t%s\nPostYearDiam\t%s\n",
254 if (Desc.
Empty()) { Desc = FNmPref; }
258 XLbl =
"Number of nodes (time)";
266 TFltPrV DegToCCfV, CcfV, OpClV, OpV;
271 printf(
"Clustering coefficient over time:\n %d edges, %d edges per bucket, %d buckets \n",
GetEdges(), 100000, TmBucketV.
Len());
273 for (
int t = 0; t < TmBucketV.
Len(); t++) {
274 printf(
"\r %d/%d: ", t+1, TmBucketV.
Len());
275 NodeIdV.
AddV(TmBucketV[t].NIdV);
276 int64 Open=0, Close=0;
280 else { XVal = TmBucketV[t].BegTm.GetInUnits(TmUnit); }
282 OpClV.
Add(
TFltPr(XVal, Open+Close==0?0:(
double)Close/(Open+Close)));
283 OpV.
Add(
TFltPr(XVal, Open==0?0:(
double)Close/Open));
286 Tuple[2]=(double)Close; Tuple[3]=(double)Open;
288 printf(
" %s", ExeTm.
GetStr());
291 "Degree",
"Clustering coefficient",
gpsLog10XY,
false);
293 TGnuPlot::PlotValV(CcfV,
"ccfOverTm."+FNmPref, Desc+
". Average Clustering Coefficient", XLbl,
"Average clustering coefficient",
gpsAuto,
false);
294 TGnuPlot::PlotValV(OpClV,
"ClsOpnTr1."+FNmPref, Desc+
". Close/(Open+Closed) triads", XLbl,
"Close / (Open+Closed) triads",
gpsAuto,
false);
304 XLbl =
"Number of nodes (time)";
IAssert(NodesPerBucket > 0);
309 printf(
"\n\n%s\nMedian degree over time:\n %d edges, %d edges per bucket, %d buckets \n", FNmPref.
CStr(),
GetEdges(), NodesPerBucket, TmBucketV.
Len());
310 TFltPrV MedDegV, MedInDegV, MedOutDegV;
315 FILE *F = fopen((
"gStat-"+FNmPref+
".tab").CStr(),
"wt");
316 fprintf(F,
"UndirNodes\tUndirEdges\tUndirNonZNodes\tMedianDeg\tMeanDeg\tDirNodes\tDirEdges\tDirNonzNodes\tMedInDeg\tMedOutDeg\tMeanInDeg\tMeanOutDeg\n");
317 for (
int t = 0; t < TmBucketV.
Len(); t++) {
318 printf(
"\r %d/%d: ", t+1, TmBucketV.
Len());
319 NodeIdV.
AddV(TmBucketV[t].NIdV);
321 else { XVal = TmBucketV[t].BegTm.GetInUnits(TmUnit); }
328 {
const PNGraph Graph = TSnap::GetSubGraph<PNGraph>(NGraph, NodeIdV);
TMom MomOut, MomIn;
330 if (NI.GetOutDeg()>0) { MomOut.
Add(NI.GetOutDeg()); }
331 if (NI.GetInDeg()>0) { MomIn.Add(NI.GetInDeg()); } }
332 MomOut.Def(); MedOutDegV.Add(
TFltPr(XVal, MomOut.GetMedian()));
333 MomIn.Def(); MedInDegV.Add(
TFltPr(XVal, MomIn.GetMedian()));
334 fprintf(F,
"\t%d\t%d\t%d\t%f\t%f\t%f\t%f\n", Graph->
GetNodes(), Graph->
GetEdges(), (int)
TSnap::CntNonZNodes(Graph), (float)MomIn.GetMedian(), (float)MomOut.GetMedian(), (float)MomIn.GetMean(), (float)MomOut.GetMean()); }
350 for (
int y = 0; y < Ss->GetYLen(); y++) {
351 if (Ss->At(0, y)[0] ==
'#')
continue;
352 if (Ss->GetXLen(y) < 3)
continue;
353 const int& SrcId = Ss->At(0, y).GetInt();
354 IAssert(! Set1IdH.IsKey(SrcId));
356 Set1IdH.AddKey(SrcId);
357 Ss->At(1, y).SplitOnAllCh(
'-', StrTimeV);
358 const int Year = StrTimeV[0].GetInt();
359 const int Month = StrTimeV[1].GetInt();
360 const int Day = StrTimeV[2].GetInt();
361 const TSecTm NodeTm(Year, Month, Day);
362 TimeNet.
AddNode(SrcId, NodeTm);
363 for (
int dst = 2; dst < Ss->GetXLen(y); dst++) {
364 const int DstId = Ss->At(dst, y).GetInt();
365 IAssert(! Set1IdH.IsKey(DstId));
366 if (! TimeNet.
IsNode(DstId)) { TimeNet.
AddNode(DstId, NodeTm); }
368 if (! TimeNet.
IsEdge(SrcId, DstId)) { TimeNet.
AddEdge(SrcId, DstId); }
372 printf(
"Bipartate graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
385 printf(
"Arxiv citation graph (paper publication year)...\n");
388 FILE *PprF = fopen(PaperFNm.
CStr(),
"rt");
390 TStrV StrV, StrTimeV;
391 int N = 0, DuplicateNode = 0;
392 while (! feof(PprF)) {
394 fgets(Line, 1024, PprF);
395 if (strlen(Line) == 0 || Line[0] ==
'#')
continue;
396 Line[strlen(Line)-1] = 0;
398 StrId = StrV[0]; StrTime = StrV[1];
IAssert(!StrId.Empty() && !StrTime.Empty());
399 StrTime.SplitOnAllCh(
'-', StrTimeV);
IAssert(StrTimeV.
Len() == 3);
400 const int NodeId = StrId.GetInt();
401 if (! TimeNet.
IsNode(NodeId)) {
402 const int Year = StrTimeV[0].GetInt();
403 const int Month = StrTimeV[1].GetInt();
404 const int Day = StrTimeV[2].GetInt();
406 }
else { DuplicateNode++; }
407 if (++N % 10000 == 0) printf(
"\r %dk", N/1000);
409 printf(
"\r %d nodes read. %d duplicate nodes. %s\n", N, DuplicateNode, ExeTm.
GetTmStr());
412 int NewSrcIds=0, NewDstIds=0, DupLinks=0, NewCits=0;
413 FILE *CiteF = fopen(CiteFNm.
CStr(),
"rt");
415 printf(
"Loading Arxiv citations...\n");
418 while (! feof(CiteF)) {
420 fgets(Line, 1024, CiteF);
421 if (strlen(Line) == 0 || Line[0] ==
'#')
continue;
422 Line[strlen(Line)-1] = 0;
424 const int SrcNId = StrV[0].GetInt();
425 const int DstNId = StrV[1].GetInt();
428 if (! TimeNet.
IsNode(DstNId) && TimeNet.
IsNode(SrcNId)) {
430 if (! NIdToTimeH.
IsKey(DstNId)) {
431 NIdToTimeH.
AddDat(DstNId, SrcTm);
434 else if (NIdToTimeH.
GetDat(DstNId) < SrcTm) {
435 NIdToTimeH.
GetDat(DstNId) = SrcTm; }
437 if (++N % 10000 == 0) printf(
"\r %dk", N/1000);
441 for (
int i = 0; i < NIdToTimeH.
Len(); i++) {
445 for (
int i = 0; i < EdgeV.
Len(); i++) {
446 const int SrcNId = EdgeV[i].Val1;
447 const int DstNId = EdgeV[i].Val2;
449 if (! TimeNet.
IsEdge(SrcNId, DstNId)) { TimeNet.
AddEdge(SrcNId, DstNId); }
452 if (! TimeNet.
IsNode(SrcNId)) {
454 if (! TimeNet.
IsNode(DstNId)) { NewCits++; }
458 printf(
"\r %d citations read. %s\n", N, ExeTm.
GetTmStr());
459 printf(
"Graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
462 for (TTimeNet::TNodeI ni = TimeNet.
BegNI(); ni < TimeNet.
EndNI(); ni++) {
463 if (ni.GetDeg() == 0) { RmNIdV.
Add(ni.GetId()); }
465 for (
int i = 0; i < RmNIdV.
Len(); i++) {
469 printf(
"\nFinal graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
470 printf(
" Duplicate citations : %d\n", DupLinks);
471 printf(
" Nodes without time which are cited : %d (add them to graph, use time of the earliest source node)\n", NewDstIds);
472 printf(
" Citations between unknown time nodes : %d\n", NewCits);
473 printf(
" Nodes without time which make citations: %d (do not add them into the graph)\n", NewSrcIds);
483 TimeNet.
Reserve(4000000, 160000000);
484 printf(
"parsing patent data (patent grant year)...\n");
486 const int& PatIdCol = 0;
487 const int& GYearCol = 1;
490 FILE *PatF = fopen(PatentFNm.
CStr(),
"rt");
491 fgets(Line, 1024, PatF);
492 while (! feof(PatF)) {
494 fgets(Line, 1024, PatF);
495 if (strlen(Line) == 0)
break;
498 const int PatentId = ColV[PatIdCol].GetInt();
499 const int GrantYear = ColV[GYearCol].GetInt();
502 if (++N % 100000 == 0) printf(
"\r %dk", N/1000);
504 printf(
"\r %d patents read. %s\n", N, ExeTm.
GetTmStr());
507 printf(
"\nLoading patent citations...\n");
508 int NewSrcIds=0, NewDstIds=0, DupLinks=0, NewCits=0;
511 FILE *CiteF = fopen(CiteFNm.
CStr(),
"rt");
512 fgets(Line, 1024, CiteF);
513 while (! feof(CiteF)) {
515 fgets(Line, 1024, CiteF);
516 if (strlen(Line) == 0)
break;
517 Line[strlen(Line)-1] = 0;
519 const int SrcNId = SrcId.
GetInt();
520 const int DstNId = DstId.
GetInt();
521 if (! TimeNet.
IsNode(SrcNId) && ! TimeNet.
IsNode(DstNId)) {
527 else if (TimeNet.
IsNode(SrcNId) && ! TimeNet.
IsNode(DstNId)) {
530 else if (! TimeNet.
IsNode(SrcNId) && TimeNet.
IsNode(DstNId)) {
533 if (! TimeNet.
IsEdge(SrcNId, DstNId)) {
534 TimeNet.
AddEdge(SrcNId, DstNId);
535 }
else { DupLinks++; }
536 if (++N % 100000 == 0) printf(
"\r %dk", N/1000);
539 printf(
"\r %d citations read. %s\n\n", N, ExeTm.
GetTmStr());
540 printf(
"Graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
543 for (TTimeNet::TNodeI ni = TimeNet.
BegNI(); ni < TimeNet.
EndNI(); ni++) {
544 if (ni.GetDeg() == 0) { RmNIdV.
Add(ni.GetId()); }
546 for (
int i = 0; i < RmNIdV.
Len(); i++) {
550 printf(
"\nFinal graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
551 printf(
" Duplicate citations : %d\n", DupLinks);
552 printf(
" Citations between unknown time nodes : %d\n", NewCits);
553 printf(
" Nodes without time which make citations: %d\n", NewSrcIds);
554 printf(
" Nodes without time which are cited : %d\n", NewDstIds);
565 printf(
"Amazon Share-the-Love...\n");
566 char line [2024], MonthStr[4];
569 FILE *F = fopen(StlFNm.
CStr(),
"rt");
571 memset(line, 0, 2024);
572 fgets(line, 2024, F);
573 if (strlen(line) == 0)
break;
575 const int SrcNId = ColV[0].GetInt();
576 const int DstNId = ColV[1].GetInt();
578 TStr TmStr = ColV[2];
580 if (Year < 10) { Year += 2000; }
else { Year += 1900; }
581 MonthStr[0]=toupper(TmStr[2]); MonthStr[1]=tolower(TmStr[3]);
582 MonthStr[2]=tolower(TmStr[4]); MonthStr[3]=0;
589 if (! TimeNet.
IsNode(SrcNId)) { TimeNet.
AddNode(SrcNId,
TSecTm(Year, Month, Day, Hour, Min, Sec)); }
590 if (! TimeNet.
IsNode(DstNId)) { TimeNet.
AddNode(DstNId,
TSecTm(Year, Month, Day, Hour, Min, Sec)); }
591 if (! TimeNet.
IsEdge(SrcNId, DstNId)) { TimeNet.
AddEdge(SrcNId, DstNId); }
592 if (++NLines % 100000 == 0) printf(
"\r %dk", NLines/1000);
595 printf(
"\r %d lines read\n", NLines);
596 printf(
"Graph: nodes: %d edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
604 if (
this != &TimeNet) {
613 for (TNodeI NI =
BegNI(); NI <
EndNI(); NI++) {
614 NewNet->AddNode(NI.GetId(), NI.GetDat());
616 for (TEdgeI EI =
BegEI(); EI <
EndEI(); EI++) {
617 const int src = EI.GetSrcNId();
618 const int dst = EI.GetDstNId();
619 if (! NewNet->IsEdge(src, dst)) {
620 NewNet->AddEdge(src, dst); }
630 for (TNodeI NI =
BegNI(); NI <
EndNI(); NI++) {
631 Net->AddNode(NI.GetId(), NI.GetDat()); }
634 for (
int edge = 0; edge < EIdV.
Len(); edge++) {
635 const TEdgeI EI =
GetEI(EIdV[edge]);
636 const int Src = EI.GetSrcNId();
637 const int Dst = EI.GetDstNId();
651 for (node = 0; node < NIdV.
Len(); node++) {
654 for (node = 0; node < NIdV.
Len(); node++) {
655 NI =
GetNI(NIdV[node]);
656 for (edge = 0; edge < NI.GetOutDeg(); edge++) {
657 const TEdgeI EI =
GetEI(NI.GetOutEId(edge));
658 if (NewNet.
IsNode(EI.GetDstNId())) {
670 for (
int edge = 0; edge < EIdV.
Len(); edge++) {
671 const TEdgeI Edge =
GetEI(EIdV[edge]);
672 if (! NewNet.
IsNode(Edge.GetSrcNId()))
674 if (! NewNet.
IsNode(Edge.GetDstNId()))
687 for (TEdgeI EI =
BegEI(); EI <
EndEI(); EI++) {
688 if (EI() > MaxEdgeTm) {
break; }
689 if (! NewNet.
IsNode(EI.GetSrcNId()))
691 if (! NewNet.
IsNode(EI.GetDstNId()))
709 for (TNodeI NI =
BegNI(); NI <
EndNI(); NI++) {
711 for (
int edge = 0; edge < NI.GetOutDeg(); edge++) {
713 if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
715 for (
int edge = 0; edge < NI.GetInDeg(); edge++) {
717 if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
720 printf(
"Update node times: %d/%d updates\n", Cnt,
GetNodes());
725 for (TNodeI NI =
BegNI(); NI <
EndNI(); NI++) {
726 if (NI.GetDeg() == 0) {
continue; }
728 for (
int edge = 0; edge < NI.GetOutDeg(); edge++) {
730 if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
732 for (
int edge = 0; edge < NI.GetInDeg(); edge++) {
734 if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
738 printf(
"Node times set: %d/%d updates\n", Cnt,
GetNodes());
743 printf(
"Shuffling last %d (%d%%) edge arrival times..\n",
GetEdges()-MinTmEdge,
int(100.0*(
GetEdges()-MinTmEdge)/
double(
GetEdges())));
745 TIntV TrueEIdV = RndEIdV;
747 const int SwapLen = RndEIdV.
Len()-MinTmEdge;
748 for (
int R = 0; R < 10; R++) {
749 for (
int i = MinTmEdge; i < RndEIdV.
Len(); i++) {
752 for (
int e = 0; e < TrueEIdV.
Len(); e++) {
754 for (
int e = 0; e < RndEIdV.
Len(); e++) {
755 GetEDat(RndEIdV[e]) = TrueTmV[e]; }
760 TSecTm MnNodeTm, MxNodeTm;
761 TSecTm MnEdgeTm, MxEdgeTm;
762 for (TNodeI NI =
BegNI(); NI <
EndNI(); NI++) {
763 const TSecTm NodeTm = NI();
764 if (! MnNodeTm.
IsDef() || MnNodeTm>NodeTm) { MnNodeTm = NodeTm; }
765 if (! MxNodeTm.
IsDef() || MxNodeTm<NodeTm) { MxNodeTm = NodeTm; }
768 for (TEdgeI EI=
BegEI(); EI <
EndEI(); EI++) {
769 const TSecTm EdgeTm = EI();
770 if (! MnEdgeTm.
IsDef() || MnEdgeTm>EdgeTm) { MnEdgeTm = EdgeTm; }
771 if (! MxEdgeTm.
IsDef() || MxEdgeTm<EdgeTm) { MxEdgeTm = EdgeTm; }
778 for (TNodeI NodeI =
BegNI(); NodeI <
EndNI(); NodeI++) {
782 for (
int i = 0; i < TmToNIdV.
Len(); i++) {
783 NIdV.
Add(TmToNIdV[i].Dat); }
788 for (TEdgeI EI=
BegEI(); EI <
EndEI(); EI++) {
792 for (
int i = 0; i < TmToEIdV.
Len(); i++) {
793 EIdV.
Add(TmToEIdV[i].Dat); }
799 for (
int n = 0; n < NIdV.
Len(); n++) {
801 if (! TmIdToNIdVH.
IsKey(TmId)) { TmIdToNIdVH.
AddKey(TmId); }
807 TmBucketV.
Gen(TmIdNIdVV.
Len());
808 for (
int i = 0; i < TmIdNIdVV.
Len(); i++) {
810 Bucket.
BegTm = TmIdNIdVV[i].Val1;
811 Bucket.
NIdV = TmIdNIdVV[i].Val2;
818 for (
int e = 0; e < EIdV.
Len(); e++) {
820 if (! TmIdToEIdVH.
IsKey(TmId)) { TmIdToEIdVH.
AddKey(TmId); }
826 TmBucketV.
Gen(TmIdEIdVV.
Len());
827 for (
int i = 0; i < TmIdEIdVV.
Len(); i++) {
829 Bucket.
BegTm = TmIdEIdVV[i].Val1;
830 Bucket.
NIdV = TmIdEIdVV[i].Val2;
836 TmBucketV.
Gen(NIdV.
Len() / NodesPerBucket + 1, 0);
837 for (
int i = 0; i < NIdV.
Len(); i++) {
838 const int b = i/NodesPerBucket;
840 TmBucketV[b].NIdV.
Add(NIdV[i]);
846 TmBucketV.
Gen(EIdV.
Len()/EdgesPerBucket + 1, 0);
847 for (
int i = 0; i < EIdV.
Len(); i++) {
848 const int b = i/EdgesPerBucket;
850 TmBucketV[b].NIdV.
Add(EIdV[i]);
860 for (
int edge = 0; edge < EIdV.
Len(); edge++) {
861 const TEdgeI EI =
GetEI(EIdV[edge]);
862 const int Src = EI.GetSrcNId();
863 const int Dst = EI.GetDstNId();
864 if (Src==Dst || Graph->
IsEdge(Src, Dst)) {
continue; }
869 if (edge % 10000 == 0) {
870 printf(
"\redges %dk / %dk: triangle edges: %dk [total %s]", edge/1000, EIdV.
Len()/1000,
883 for (
int t = 0; t < TmBucketV.
Len(); t++) {
884 EdgeIdV.
AddV(TmBucketV[t].NIdV);
885 printf(
"\n***%d/%d: %s (%d edges) ", t+1, TmBucketV.
Len(), TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.
Len()); ExeTm.
Tick();
886 if (TmBucketV[t].BegTm < StartTm) {
continue; }
888 GStatVec->Add(PreGraph, TmBucketV[t].BegTm);
889 printf(
" [%s]\n", ExeTm.
GetTmStr());
897 const TTmUnit& TmUnit,
const int& TakeNTmUnits,
const bool& LinkBWays)
const {
904 for (
int t = 0; t < TmBucketV.
Len(); t++) {
906 if (TakeNTmUnits == -1) {
907 EdgeIdV.
AddV(TmBucketV[t].NIdV); }
909 if (t < TakeNTmUnits) {
continue; }
911 for (
int i = t-TakeNTmUnits; i < t; i++) { EdgeIdV.
AddV(TmBucketV[i].NIdV); }
913 printf(
"*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.
Len()); ExeTm.
Tick();
917 for (
TNEGraph::TEdgeI EI = PreGraph->BegEI(); EI < PreGraph->EndEI(); EI++) {
918 if (PreGraph->IsEdge(EI.GetDstNId(), EI.GetSrcNId(),
true)) { KeepEIdV.
Add(EI.GetId()); }
923 GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
925 GrowthStat->
Save(FOut); }
926 GrowthStat->SaveTxt(FNmPref, Desc);
927 printf(
" [%s]\n", ExeTm.
GetTmStr());
933 const TSecTm& StartTm,
const int& NDiamRuns,
const bool& OnlyWcc)
const {
940 for (
int t = 0; t < TmBucketV.
Len(); t++) {
941 EdgeIdV.
AddV(TmBucketV[t].NIdV);
942 printf(
"\n*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr(TmUnit).CStr(), EdgeIdV.
Len()); ExeTm.
Tick();
943 if (TmBucketV[t].BegTm < StartTm)
continue;
944 PNGraph PreGraph = TSnap::ConvertESubGraph<PNGraph>(FullGraph, EdgeIdV);
946 double EffDiam = 0.0;
947 for (
int r = 0; r < NDiamRuns; r++) {
948 printf(
"%d...", r+1); Run1Tm.
Tick();
952 printf(
"[%s]\r", Run1Tm.
GetTmStr());
955 TmDiamV.
Add(
TFltTr(TmBucketV[t].BegTm.Round(TmUnit).GetAbsSecs(), Mom.GetMean(), Mom.GetSDev()));
958 printf(
" [%s] \n", ExeTm.
GetTmStr());
965 GnuPlot.
SetXYLabel(
"NODES",
"AVERAGE "+WccStr+
"Effective Diameter");
976 const TSecTm& DelPreTmEdges,
const TSecTm& PostTmDiam,
const bool& LinkBWays) {
977 printf(
"\nGrowth over time: degree distribution, Growth Power Law, Diameter.\n %s group by %s.\n",
979 printf(
" Delete out-edges of pre time %s nodes.\n Take subgraph of post year %s subgraph.\n\n",
1225 printf(
"Generating G_nm(%d, %d)\n", Nodes, Edges);
1228 Net->Reserve(Nodes, Edges);
1229 for (
int e = 0; e < Edges; e++) {
1232 while (Dst == Src || Net->IsEdge(Src, Dst)) {
1234 if (! Net->IsNode(Src)) { Net->AddNode(Src,
TSecTm(e)); }
1235 if (! Net->IsNode(Dst)) { Net->AddNode(Dst,
TSecTm(e)); }
1236 Net->AddEdge(Src, Dst, -1,
TSecTm(e));
1243 const double Alpha = Nodes/double(Edges);
1244 printf(
"Generating PA(%d, %d), with slope in:%.1f, out: %.1f\n", Nodes, Edges,
1245 2+GammaIn/(Alpha/(1-Alpha)), 2+GammaOut/(Alpha/(1-Alpha)));
1247 int nodes=0, edges=0, time=0, iter=0;
1248 TIntV OutW(Edges, 0), InW(Edges, 0);
1250 Net->Reserve(Nodes, Edges);
1252 Net->AddNode(0,
TSecTm(time++)); nodes++;
1253 OutW.Add(0); InW.
Add(0);
1254 while (edges < Edges) {
1255 int Src=-1, Dst=-1; iter++;
1257 if (nodes < Nodes) {
1261 if (
TInt::Rnd.GetUniDev() < nodes*GammaIn/double(edges+nodes*GammaIn)) {
1264 if (
TInt::Rnd.GetUniDev() < nodes*GammaOut/double(edges+nodes*GammaOut)) {
1268 if (Src == Dst || Net->IsEdge(Src, Dst)) {
1272 if (! Net->IsNode(Src)) { Net->AddNode(Src,
TSecTm(time++)); nodes++; }
1273 if (! Net->IsNode(Dst)) { Net->AddNode(Dst,
TSecTm(time++)); nodes++; }
1274 Net->AddEdge(Src, Dst, -1,
TSecTm(time++));
1275 OutW.Add(Src); InW.
Add(Dst); edges++;
1277 for (
int node = 0; node < Nodes; node++) {
1278 if (! Net->IsNode(node)) {
1279 Net->AddNode(node,
TSecTm(time++)); }
1285 printf(
"Generating PA, nodes:%d, out-deg:%d\n", Nodes, OutDeg);
1289 Net->Reserve(Nodes, OutDeg*Nodes);
1290 Net->AddNode(0,
TSecTm(++time)); Net->AddNode(1,
TSecTm(++time));
1291 Net->AddEdge(0, 1, -1,
TSecTm(++time));
1294 for (
int node = 2; node <= Nodes; node++) {
1296 while (NodeSet.
Len() < OutDeg && NodeSet.
Len() < node) {
1299 const int N = Net->AddNode(node,
TSecTm(++time));
1300 for (
int i = 0; i < NodeSet.
Len(); i++) {
1301 Net->AddEdge(node, NodeSet[i], -1,
TSecTm(++time));
1302 NIdV.
Add(N); NIdV.
Add(NodeSet[i]);
1313 FILE *F = fopen(EdgeFNm.
CStr(),
"wt");
1316 for (
int e =0; e < EIdV.
Len(); e++) {
1317 const TEdgeI EI =
GetEI(EIdV[e]);
1319 const int src = EI.GetSrcNId();
1320 const int dst = EI.GetDstNId();
1322 fprintf(F,
"%d\t%d\t%d\n", NIdMap.
GetKeyId(src), NIdMap.
GetKeyId(dst), EI().GetAbsSecs()-BegTm);
1324 fprintf(F,
"%d\t%d\t%d\n", EI.GetSrcNId(), EI.GetDstNId(), EI().GetAbsSecs()-BegTm); }
1331 for (
int i = 1; i <= 6; i++) {
1332 Net->AddNode(i,
TSecTm(0)); }
1334 Net->AddEdge(1, 2, -1,
TSecTm(tm++));
1335 Net->AddEdge(3, 4, -1,
TSecTm(tm++));
1336 Net->AddEdge(3, 1, -1,
TSecTm(tm++));
1337 Net->AddEdge(5, 6, -1,
TSecTm(tm++));
1338 Net->AddEdge(6, 4, -1,
TSecTm(tm++));
1339 Net->AddEdge(5, 3, -1,
TSecTm(tm++));
1340 Net->AddEdge(5, 4, -1,
TSecTm(tm++));
1341 Net->AddEdge(5, 2, -1,
TSecTm(tm++));
1346 const int BegOfTm = 1047369600;
1348 printf(
"Adding nodes...");
1351 const int NId = Ss.
GetInt(0);
1352 const int Tm = Ss.
GetInt(1)+BegOfTm;
1354 printf(
" skip node %g (time %d)\n", (
double) Ss.
GetLineNo(), Ss.
GetInt(1));
continue; }
1355 Net->AddNode(NId,
TSecTm(Tm));
1357 printf(
" %d nodes\n", Net->GetNodes());
1358 printf(
"Adding edges...");
1363 const int NId1 = Ss.
GetInt(0);
1364 const int NId2 = Ss.
GetInt(1);
1366 if (! Net->IsNode(NId1) || ! Net->IsNode(NId2)) { printf(
"not node\n");
continue; }
1367 if (Tm <
TSecTm(2002, 1, 1)) { SkipCnt++;
1368 printf(
" skip edge %g (time %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr());
continue; }
1369 if (Tm+600 < Net->GetNDat(NId1)) {
1370 printf(
" 1:skip edge %g (time %s < %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr(), Net->GetNDat(NId1).GetStr().CStr());
1372 SkipCnt++;
continue; }
1373 if (Tm+600 < Net->GetNDat(NId2)) { SkipCnt++;
1374 printf(
" 2:skip edge %g (time %s < %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr(), Net->GetNDat(NId2).GetStr().CStr());
1376 SkipCnt++;
continue; }
1377 Net->AddEdge(NId1, NId2, -1,
TSecTm(Tm));
1380 printf(
" %d edges\n", Net->GetEdges());
1381 printf(
" %d edges skipped (edge time < node time)\n", SkipCnt);
1382 Net->UpdateNodeTimes();
1389 printf(
"Loading %s\n", EdgeFNm.
CStr());
1397 if (Ss.
IsCmt()) {
continue; }
1399 const char* Node1 = Ss.
GetFld(SrcFld);
1400 const char* Node2 = Ss.
GetFld(DstFld);
1401 const char* TmStr = Ss.
GetFld(TimeFld);
1402 if (strcmp(TmStr,
"NULL")==0) {
continue; }
1404 const TSecTm Tm(atoi(TmStr));
1405 const int NId1 = StrToId.
AddKey(Node1);
1406 const int NId2 = StrToId.
AddKey(Node2);
1407 if (! Net->IsNode(NId1)) { Net->AddNode(NId1,
TSecTm()); }
1408 if (! Net->IsNode(NId2)) { Net->AddNode(NId2,
TSecTm()); }
1411 Net->AddEdge(NId1, NId2, -1, Tm);
1412 if (++LineCnt % 1000 == 0) {
1413 printf(
"\r %dk lines processed: %d %d [%s]", LineCnt/1000, Net->GetNodes(), Net->GetEdges(), ExeTm.
GetStr()); }
1415 printf(
"\r %d lines processed: %d %d [%s]\n", LineCnt, Net->GetNodes(), Net->GetEdges(), ExeTm.
GetStr());
1416 printf(
" Data range %s -- %s\n", MinTm.
GetStr().
CStr(), MaxTm.GetStr().CStr());
1418 Net->UpdateNodeTimes();
void Clr(const bool &DoDel=true, const int &NoDelLim=-1)
PTimeNENet GetTimeNENet() const
static const T & Mn(const T &LVal, const T &RVal)
TPair< TInt, TInt > TIntPr
void PlotEffDiam(const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &StartTm, const int &NDiamRuns=10, const bool &OnlyWcc=false) const
static PTimeNet LoadArxiv(const TStr &PaperFNm, const TStr &CiteFNm)
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
static PSs LoadTxt(const TSsFmt &SsFmt, const TStr &FNm, const PNotify &Notify=NULL, const bool &IsExcelEoln=true, const int &MxY=-1, const TIntV &AllowedColNV=TIntV(), const bool &IsQStr=true)
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
static PTimeNENet GetSmallNet()
double GetBfsEffDiam(const PGraph &Graph, const int &NTestNodes, const bool &IsDir=false)
Returns the (approximation of the) Effective Diameter (90-th percentile of the distribution of shorte...
void SavePng(const int &SizeX=1000, const int &SizeY=800, const TStr &Comment=TStr())
PGraph GetMxWcc(const PGraph &Graph)
Returns a graph representing the largest weakly connected component on an input Graph.
static const T & Mx(const T &LVal, const T &RVal)
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
PTimeNENet Get1stEdgeNet() const
int GetKeyId(const TKey &Key) const
void PlotMissingPast(const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &DelPreTmEdges, const TSecTm &PostTmDiam) const
void GetNIdByTm(TIntV &NIdV) const
void PlotMissingPast(const TStr &FNmPref, const TStr &Desc, const TTmUnit &TmUnit, const TSecTm &DelPreTmEdges, const TSecTm &PostTmDiam, const bool &LinkBWays)
int GetEdges() const
Returns the number of edges in the graph.
void GetEIdByTm(TIntV &EIdV) const
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
int GetEdges() const
Returns the number of edges in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
void PlotCCfOverTm(const TStr &FNmPref, TStr Desc, const TTmUnit &TmUnit, const int &NodesBucket=-1) const
Node iterator. Only forward iteration (operator++) is supported.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
int GetNodes() const
Returns the number of nodes in the network.
double GetAnfEffDiam(const PGraph &Graph, const bool &IsDir, const double &Percentile, const int &NApprox)
void Gen(const int &ExpectVals)
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
int GetEdges() const
Returns the number of edges in the network.
PGStatVec TimeGrowth(const TTmUnit &TimeStep, const TFSet &TakeStat, const TSecTm &StartTm=TSecTm(1)) const
int GetNodes() const
Returns the number of nodes in the graph.
TStr GetSubStr(const int &BChN, const int &EChN) const
void SetXYLabel(const TStr &XLabel, const TStr &YLabel)
void GetEdgeBuckets(const int EdgesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
void GetTmBuckets(const TTmUnit &GroupBy, TTmBucketV &TmBucketV) const
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
static PTimeNet LoadPatents(const TStr &PatentFNm, const TStr &CiteFNm)
bool GetInt(const int &FldN, int &Val) const
If the field FldN is an integer its value is returned in Val and the function returns true...
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Edge iterator. Only forward iteration (operator++) is supported.
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
const TDat & GetDat(const TKey &Key) const
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
int GetNodes() const
Returns the number of nodes in the network.
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
bool IsKey(const TKey &Key) const
PTimeNENet GetGraphUpToTm(const TSecTm &MaxEdgeTm) const
int GetNodes() const
Returns the number of nodes in the graph.
const char * GetFld(const int &FldN) const
Returns the contents of the field at index FldN.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
TSsFmt
Spread-Sheet Separator Format.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge between node IDs SrcNId and DstNId to the graph.
bool Empty() const
Tests whether the vector is empty.
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
static PTimeNENet LoadEdgeTm(const TStr &EdgeFNm, const int &SrcFld=0, const int &DstFld=1, const int &TimeFld=2, const TSsFmt &Separator=ssfTabSep)
void SaveEdgeTm(const TStr &EdgeFNm, const bool &RenumberNId=false, const bool &RelativeTm=false) const
Graph Statistics Sequence.
void SplitOnCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
static void SaveTs(const TIntKdV &KdV, const TStr &FNm, const TStr &HeadLn=TStr())
const char * GetTmStr() const
void DelNode(const int &NId)
Deletes node of ID NId from the network.
void PlotEffDiam(const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &StartTm, const int &NDiamRuns=10, const bool &OnlyWcc=false, const bool &AlsoRewire=false) const
void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
static PTimeNENet GetPrefAttach(const int &Nodes, const int &Edges, const double &GammaIn, const double &GammaOut)
void Add(const TFlt &Val, const TFlt &Wgt=1)
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Statistics of a Graph Snapshot.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the network.
void SetNodeTmToFirstEdgeTm()
int CntNonZNodes(const PGraph &Graph)
Returns the number of nodes with degree greater than 0.
PUNGraph GetSubGraph(const PUNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes)
Returns an induced subgraph of an undirected graph Graph with NIdV nodes with an optional node renumb...
Whitespace (space or tab) separated.
THash< TInt, TNode > NodeH
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New().
int AddKey(const TKey &Key)
void DumpTimeStat() const
void SetRndEdgeTimes(const int &MinTmEdge=0)
void DelEdge(const int &SrcNId, const int &DstNId)
Deletes an edge between node IDs SrcNId and DstNId from the graph.
int Len() const
Returns the number of fields in the current line.
TTriple< TFlt, TFlt, TFlt > TFltTr
PUNGraph GenConfModel(const TIntV &DegSeqV, TRnd &Rnd)
Generates a random undirect graph with a given degree sequence.
TNodeEdgeNet & operator=(const TNodeEdgeNet &Net)
PTimeNENet GetSubGraph(const TIntV &NIdV) const
THash< TInt, TEdge > EdgeH
TPair< TFlt, TFlt > TFltPr
void PlotMedianDegOverTm(const TStr &FNmPref, const TTmUnit &TmUnit, const int &NodesPerBucket=-1) const
void SetVal(const TGStatVal &StatVal, const double &Val)
static PTimeNet LoadBipartite(const TStr &InFNm)
int CntInDegNodes(const PGraph &Graph, const int &NodeInDeg)
Returns the number of nodes with in-degree NodeInDeg.
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph.
int AddKey(const char *Key)
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
static PTimeNENet LoadFlickr(const TStr &NodeFNm, const TStr &EdgeFNm)
PTimeNENet GetESubGraph(const TIntV &EIdV) const
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
static PTimeNENet GetGnmRndNet(const int &Nodes, const int &Edges)
int AddKey(const TKey &Key)
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
TTimeNENet & operator=(const TTimeNENet &TimeNet)
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
void GetNIdByTm(TIntV &NIdV) const
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
void Save(TSOut &SOut) const
TStr GetStr(const TLoc &Loc=lUs) const
TNodeNet & operator=(const TNodeNet &NodeNet)
static void PlotValV(const TVec< TPair< TVal1, TVal2 > > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
static TStr Fmt(const char *FmtStr,...)
uint64 GetLineNo() const
Returns the line number of the current line.
int GetTriadEdges(TIntV &TriadEIdV) const
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
int GetEdges() const
Returns the number of edges in the network.
static int GetMonthN(const TStr &MonthNm, const TLoc &Loc=lUs)
Node iterator. Only forward iteration (operator++) is supported.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph.
void GetKeyDatPrV(TVec< TPair< TKey, TDat > > &KeyDatPrV) const
void GetTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
double GetClustCf(const PGraph &Graph, int SampleNodes=-1)
Computes the average clustering coefficient as defined in Watts and Strogatz, Collective dynamics of ...
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
bool Next()
Loads next line from the input file.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
int GetUniDevInt(const int &Range=0)
PTimeNet GetTimeNet() const
PGraph GetESubGraph(const PGraph &Graph, const TIntV &EIdV)
Returns a subgraph of graph Graph with EIdV edges.
void SplitOnWs(TStrV &StrV) const
TTimeNet & operator=(const TTimeNet &TimeNet)
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
const char * GetStr() const
bool IsEdge(const int &SrcNId, const int &DstNId) const
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.
int CntDegNodes(const PGraph &Graph, const int &NodeDeg)
Returns the number of nodes with degree NodeDeg.
bool IsKey(const TKey &Key) const
static PGStatVec New(const TTmUnit &_TmUnit=tmu1Sec)
static PTimeNet LoadAmazon(const TStr &StlFNm)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
PTimeNet GetSubGraph(const TIntV &NIdV) const
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
TDat & AddDat(const TKey &Key)
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
PGStatVec TimeGrowth(const TTmUnit &TmUnit, const TFSet &TakeStat, const TSecTm &StartTm) const
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
int GetCmnNbrs(const PGraph &Graph, const int &NId1, const int &NId2)
Returns a number of shared neighbors between a pair of nodes NId1 and NId2.
const TKey & GetKey(const int &KeyId) const
bool IsCmt() const
Checks whether the current line is a comment (starts with '#').
int CntOutDegNodes(const PGraph &Graph, const int &NodeOutDeg)
Returns the number of nodes with out-degree NodeOutDeg.
TSecTm Round(const TTmUnit &TmUnit) const
TPt< TTimeNENet > PTimeNENet
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
void TakeBasicStat(const PGraph &Graph, const bool &IsMxWcc=false)
void SortByDat(const bool &Asc=true)