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();
 
  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     double FltOpen = 
static_cast<double>(Open);
 
  283     double FltClose = 
static_cast<double>(Close);
 
  284     OpClV.
Add(
TFltPr(XVal, (Open+Close==0 ? 0.0 : FltClose/(FltOpen+FltClose))));
 
  285     OpV.
Add(
TFltPr(XVal, (Open==0 ? 0.0 : FltClose/FltOpen)));
 
  288     Tuple[2]=FltClose;  Tuple[3]=FltOpen;
 
  290     printf(
" %s", ExeTm.
GetStr());
 
  293       "Degree", 
"Clustering coefficient", 
gpsLog10XY, 
false);
 
  295   TGnuPlot::PlotValV(CcfV, 
"ccfOverTm."+FNmPref, Desc+
". Average Clustering Coefficient", XLbl, 
"Average clustering coefficient", 
gpsAuto, 
false);
 
  296   TGnuPlot::PlotValV(OpClV, 
"ClsOpnTr1."+FNmPref, Desc+
". Close/(Open+Closed) triads", XLbl, 
"Close / (Open+Closed) triads", 
gpsAuto, 
false);
 
  306     XLbl = 
"Number of nodes (time)";  
IAssert(NodesPerBucket > 0);
 
  311   printf(
"\n\n%s\nMedian degree over time:\n  %d edges, %d edges per bucket, %d buckets \n", FNmPref.
CStr(), 
GetEdges(), NodesPerBucket, TmBucketV.
Len());
 
  312   TFltPrV MedDegV, MedInDegV, MedOutDegV;
 
  317   FILE  *F = fopen((
"gStat-"+FNmPref+
".tab").CStr(), 
"wt");
 
  318   fprintf(F, 
"UndirNodes\tUndirEdges\tUndirNonZNodes\tMedianDeg\tMeanDeg\tDirNodes\tDirEdges\tDirNonzNodes\tMedInDeg\tMedOutDeg\tMeanInDeg\tMeanOutDeg\n");
 
  319   for (
int t = 0; t < TmBucketV.
Len(); t++) {
 
  320     printf(
"\r  %d/%d: ", t+1, TmBucketV.
Len());
 
  321     NodeIdV.
AddV(TmBucketV[t].NIdV); 
 
  323     else { XVal = TmBucketV[t].BegTm.GetInUnits(TmUnit); }
 
  330     { 
const PNGraph Graph = TSnap::GetSubGraph<PNGraph>(NGraph, NodeIdV); 
TMom MomOut, MomIn;
 
  332       if (NI.GetOutDeg()>0) { MomOut.
Add(NI.GetOutDeg()); }
 
  333       if (NI.GetInDeg()>0) { MomIn.Add(NI.GetInDeg()); } }
 
  334     MomOut.Def();  MedOutDegV.Add(
TFltPr(XVal, MomOut.GetMedian()));
 
  335     MomIn.Def();  MedInDegV.Add(
TFltPr(XVal, MomIn.GetMedian()));
 
  336     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()); }
 
  352   for (
int y = 0; y < Ss->GetYLen(); y++) {
 
  353     if (Ss->At(0, y)[0] == 
'#') 
continue; 
 
  354     if (Ss->GetXLen(y) < 3) 
continue;     
 
  355     const int& SrcId = Ss->At(0, y).GetInt();
 
  356     IAssert(! Set1IdH.IsKey(SrcId));
 
  358     Set1IdH.AddKey(SrcId);
 
  359     Ss->At(1, y).SplitOnAllCh(
'-', StrTimeV);
 
  360     const int Year = StrTimeV[0].GetInt();
 
  361     const int Month = StrTimeV[1].GetInt();
 
  362     const int Day = StrTimeV[2].GetInt();
 
  363     const TSecTm NodeTm(Year, Month, Day);
 
  364     TimeNet.
AddNode(SrcId, NodeTm);
 
  365     for (
int dst = 2; dst < Ss->GetXLen(y); dst++) {
 
  366       const int DstId = Ss->At(dst, y).GetInt();
 
  367       IAssert(! Set1IdH.IsKey(DstId));
 
  368       if (! TimeNet.
IsNode(DstId)) { TimeNet.
AddNode(DstId, NodeTm); }
 
  370       if (! TimeNet.
IsEdge(SrcId, DstId)) { TimeNet.
AddEdge(SrcId, DstId); }
 
  374   printf(
"Bipartate graph: nodes: %d  edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  387   printf(
"Arxiv citation graph (paper publication year)...\n");
 
  390   FILE *PprF = fopen(PaperFNm.
CStr(), 
"rt");
 
  392   TStrV StrV, StrTimeV;
 
  393   int N = 0, DuplicateNode = 0;
 
  394   while (! feof(PprF)) {
 
  396     fgets(Line, 1024, PprF);
 
  397     if (strlen(Line) == 0 || Line[0] == 
'#') 
continue;
 
  398     Line[strlen(Line)-1] = 0; 
 
  400     StrId = StrV[0];  StrTime = StrV[1];  
IAssert(!StrId.Empty() && !StrTime.Empty());
 
  401     StrTime.SplitOnAllCh(
'-', StrTimeV);  
IAssert(StrTimeV.
Len() == 3);
 
  402     const int NodeId = StrId.GetInt();
 
  403     if (! TimeNet.
IsNode(NodeId)) {
 
  404       const int Year = StrTimeV[0].GetInt();
 
  405       const int Month = StrTimeV[1].GetInt();
 
  406       const int Day = StrTimeV[2].GetInt();
 
  408     } 
else { DuplicateNode++; }
 
  409     if (++N % 10000 == 0) printf(
"\r  %dk", N/1000);
 
  411   printf(
"\r  %d nodes read. %d duplicate nodes. %s\n", N, DuplicateNode, ExeTm.
GetTmStr());
 
  414   int NewSrcIds=0, NewDstIds=0, DupLinks=0, NewCits=0;
 
  415   FILE *CiteF = fopen(CiteFNm.
CStr(), 
"rt");
 
  417   printf(
"Loading Arxiv citations...\n");
 
  420   while (! feof(CiteF)) {
 
  422     fgets(Line, 1024, CiteF);
 
  423     if (strlen(Line) == 0 || Line[0] == 
'#') 
continue;
 
  424     Line[strlen(Line)-1] = 0; 
 
  426     const int SrcNId = StrV[0].GetInt();
 
  427     const int DstNId = StrV[1].GetInt();
 
  430     if (! TimeNet.
IsNode(DstNId) && TimeNet.
IsNode(SrcNId)) {
 
  432       if (! NIdToTimeH.
IsKey(DstNId)) {
 
  433         NIdToTimeH.
AddDat(DstNId, SrcTm);
 
  436       else if (NIdToTimeH.
GetDat(DstNId) < SrcTm) {
 
  437         NIdToTimeH.
GetDat(DstNId) = SrcTm; }
 
  439     if (++N % 10000 == 0) printf(
"\r  %dk", N/1000);
 
  443   for (
int i = 0; i < NIdToTimeH.
Len(); i++) {
 
  447   for (
int i = 0; i < EdgeV.
Len(); i++) {
 
  448     const int SrcNId = EdgeV[i].Val1;
 
  449     const int DstNId = EdgeV[i].Val2;
 
  451       if (! TimeNet.
IsEdge(SrcNId, DstNId)) { TimeNet.
AddEdge(SrcNId, DstNId); }
 
  454       if (! TimeNet.
IsNode(SrcNId)) {
 
  456         if (! TimeNet.
IsNode(DstNId)) { NewCits++; }
 
  460   printf(
"\r  %d citations read. %s\n", N, ExeTm.
GetTmStr());
 
  461   printf(
"Graph: nodes: %d    edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  464   for (TTimeNet::TNodeI ni = TimeNet.
BegNI(); ni < TimeNet.
EndNI(); ni++) {
 
  465     if (ni.GetDeg() == 0) { RmNIdV.
Add(ni.GetId()); }
 
  467   for (
int i = 0; i < RmNIdV.
Len(); i++) {
 
  471   printf(
"\nFinal graph: nodes: %d    edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  472   printf(
"  Duplicate citations                    : %d\n", DupLinks);
 
  473   printf(
"  Nodes without time which are cited     : %d (add them to graph, use time of the earliest source node)\n", NewDstIds);
 
  474   printf(
"  Citations between unknown time nodes   : %d\n", NewCits);
 
  475   printf(
"  Nodes without time which make citations: %d (do not add them into the graph)\n", NewSrcIds);
 
  485   TimeNet.
Reserve(4000000, 160000000);
 
  486   printf(
"parsing patent data (patent grant year)...\n");
 
  488   const int& PatIdCol = 0;
 
  489   const int& GYearCol = 1;
 
  492   FILE *PatF = fopen(PatentFNm.
CStr(), 
"rt");
 
  493   fgets(Line, 1024, PatF); 
 
  494   while (! feof(PatF)) {
 
  496     fgets(Line, 1024, PatF);
 
  497     if (strlen(Line) == 0) 
break;
 
  500     const int PatentId = ColV[PatIdCol].GetInt();
 
  501     const int GrantYear = ColV[GYearCol].GetInt();
 
  504     if (++N % 100000 == 0) printf(
"\r  %dk", N/1000);
 
  506   printf(
"\r  %d patents read. %s\n", N, ExeTm.
GetTmStr());
 
  509   printf(
"\nLoading patent citations...\n");
 
  510   int NewSrcIds=0, NewDstIds=0, DupLinks=0, NewCits=0;
 
  513   FILE *CiteF = fopen(CiteFNm.
CStr(), 
"rt");
 
  514   fgets(Line, 1024, CiteF); 
 
  515   while (! feof(CiteF)) {
 
  517     fgets(Line, 1024, CiteF);
 
  518     if (strlen(Line) == 0) 
break;
 
  519     Line[strlen(Line)-1] = 0; 
 
  521     const int SrcNId = SrcId.
GetInt();
 
  522     const int DstNId = DstId.
GetInt();
 
  523     if (! TimeNet.
IsNode(SrcNId) && ! TimeNet.
IsNode(DstNId)) {
 
  529     else if (TimeNet.
IsNode(SrcNId) && ! TimeNet.
IsNode(DstNId)) {
 
  532     else if (! TimeNet.
IsNode(SrcNId) && TimeNet.
IsNode(DstNId)) {
 
  535     if (! TimeNet.
IsEdge(SrcNId, DstNId)) {
 
  536       TimeNet.
AddEdge(SrcNId, DstNId);
 
  537     } 
else { DupLinks++; }
 
  538     if (++N % 100000 == 0) printf(
"\r  %dk", N/1000);
 
  541   printf(
"\r  %d citations read. %s\n\n", N, ExeTm.
GetTmStr());
 
  542   printf(
"Graph: nodes: %d    edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  545   for (TTimeNet::TNodeI ni = TimeNet.
BegNI(); ni < TimeNet.
EndNI(); ni++) {
 
  546     if (ni.GetDeg() == 0) { RmNIdV.
Add(ni.GetId()); }
 
  548   for (
int i = 0; i < RmNIdV.
Len(); i++) {
 
  552   printf(
"\nFinal graph: nodes: %d    edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  553   printf(
"  Duplicate citations                    : %d\n", DupLinks);
 
  554   printf(
"  Citations between unknown time nodes   : %d\n", NewCits);
 
  555   printf(
"  Nodes without time which make citations: %d\n", NewSrcIds);
 
  556   printf(
"  Nodes without time which are cited     : %d\n", NewDstIds);
 
  567   printf(
"Amazon Share-the-Love...\n");
 
  568   char line [2024], MonthStr[4];
 
  571   FILE *F = fopen(StlFNm.
CStr(), 
"rt");
 
  573     memset(line, 0, 2024);
 
  574     fgets(line, 2024, F);
 
  575     if (strlen(line) == 0) 
break;
 
  577     const int SrcNId = ColV[0].GetInt();
 
  578     const int DstNId = ColV[1].GetInt();
 
  580     TStr TmStr = ColV[2]; 
 
  582     if (Year < 10) { Year += 2000; } 
else { Year += 1900; }
 
  583     MonthStr[0]=toupper(TmStr[2]);  MonthStr[1]=tolower(TmStr[3]);
 
  584     MonthStr[2]=tolower(TmStr[4]);  MonthStr[3]=0;
 
  591     if (! TimeNet.
IsNode(SrcNId)) { TimeNet.
AddNode(SrcNId, 
TSecTm(Year, Month, Day, Hour, Min, Sec)); }
 
  592     if (! TimeNet.
IsNode(DstNId)) { TimeNet.
AddNode(DstNId, 
TSecTm(Year, Month, Day, Hour, Min, Sec)); }
 
  593     if (! TimeNet.
IsEdge(SrcNId, DstNId)) { TimeNet.
AddEdge(SrcNId, DstNId); }
 
  594     if (++NLines % 100000 == 0) printf(
"\r  %dk", NLines/1000);
 
  597   printf(
"\r  %d lines read\n", NLines);
 
  598   printf(
"Graph: nodes: %d  edges: %d\n", TimeNet.
GetNodes(), TimeNet.
GetEdges());
 
  606   if (
this != &TimeNet) {
 
  615   for (TNodeI NI = 
BegNI(); NI < 
EndNI(); NI++) {
 
  616     NewNet->AddNode(NI.GetId(), NI.GetDat());
 
  618   for (TEdgeI EI = 
BegEI(); EI < 
EndEI(); EI++) {
 
  619     const int src = EI.GetSrcNId();
 
  620     const int dst = EI.GetDstNId();
 
  621     if (! NewNet->IsEdge(src, dst)) {
 
  622       NewNet->AddEdge(src, dst); }
 
  632   for (TNodeI NI = 
BegNI(); NI < 
EndNI(); NI++) {
 
  633     Net->AddNode(NI.GetId(), NI.GetDat()); }
 
  638     const int Src = EI.GetSrcNId();
 
  639     const int Dst = EI.GetDstNId();
 
  653   for (node = 0; node < NIdV.
Len(); node++) {
 
  656   for (node = 0; node < NIdV.
Len(); node++) {
 
  657     NI = 
GetNI(NIdV[node]);
 
  658     for (edge = 0; edge < NI.GetOutDeg(); edge++) {
 
  659       const TEdgeI EI = 
GetEI(NI.GetOutEId(edge));
 
  660       if (NewNet.
IsNode(EI.GetDstNId())) {
 
  674     if (! NewNet.
IsNode(Edge.GetSrcNId()))
 
  676     if (! NewNet.
IsNode(Edge.GetDstNId()))
 
  689   for (TEdgeI EI = 
BegEI(); EI < 
EndEI(); EI++) {
 
  690     if (EI() > MaxEdgeTm) { 
break; }
 
  691     if (! NewNet.
IsNode(EI.GetSrcNId()))
 
  693     if (! NewNet.
IsNode(EI.GetDstNId()))
 
  711   for (TNodeI NI = 
BegNI(); NI < 
EndNI(); NI++) {
 
  715       if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
 
  719       if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
 
  722   printf(
"Update node times: %d/%d updates\n", Cnt, 
GetNodes());
 
  727   for (TNodeI NI = 
BegNI(); NI < 
EndNI(); NI++) {
 
  728     if (NI.GetDeg() == 0) { 
continue; }
 
  732       if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
 
  736       if (! NodeTm.
IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
 
  740   printf(
"Node times set: %d/%d updates\n", Cnt, 
GetNodes());
 
  745   printf(
"Shuffling last %d (%d%%) edge arrival times..\n", 
GetEdges()-MinTmEdge, 
int(100.0*(
GetEdges()-MinTmEdge)/
double(
GetEdges())));
 
  747   TIntV TrueEIdV = RndEIdV;
 
  749   const int SwapLen = RndEIdV.
Len()-MinTmEdge;
 
  750   for (
int R = 0; R < 10; R++) {
 
  751     for (
int i = MinTmEdge; i < RndEIdV.
Len(); i++) {
 
  754   for (
int e = 0; e < TrueEIdV.
Len(); e++) {
 
  756   for (
int e = 0; e < RndEIdV.
Len(); e++) {
 
  757     GetEDat(RndEIdV[e]) = TrueTmV[e]; }
 
  762   TSecTm MnNodeTm, MxNodeTm;
 
  763   TSecTm MnEdgeTm, MxEdgeTm;
 
  764   for (TNodeI NI = 
BegNI(); NI < 
EndNI(); NI++) {
 
  765     const TSecTm NodeTm = NI();
 
  766     if (! MnNodeTm.
IsDef() || MnNodeTm>NodeTm) { MnNodeTm = NodeTm; }
 
  767     if (! MxNodeTm.
IsDef() || MxNodeTm<NodeTm) { MxNodeTm = NodeTm; }
 
  770   for (TEdgeI EI= 
BegEI(); EI < 
EndEI(); EI++) {
 
  771     const TSecTm EdgeTm = EI();
 
  772     if (! MnEdgeTm.
IsDef() || MnEdgeTm>EdgeTm) { MnEdgeTm = EdgeTm; }
 
  773     if (! MxEdgeTm.
IsDef() || MxEdgeTm<EdgeTm) { MxEdgeTm = EdgeTm; }
 
  780   for (TNodeI NodeI = 
BegNI(); NodeI < 
EndNI(); NodeI++) {
 
  784   for (
int i = 0; i < TmToNIdV.
Len(); i++) {
 
  785     NIdV.
Add(TmToNIdV[i].Dat); }
 
  790   for (TEdgeI EI= 
BegEI(); EI < 
EndEI(); EI++) {
 
  794   for (
int i = 0; i < TmToEIdV.
Len(); i++) {
 
  795     EIdV.
Add(TmToEIdV[i].Dat); }
 
  801   for (
int n = 0; n < NIdV.
Len(); n++) {
 
  803     if (! TmIdToNIdVH.
IsKey(TmId)) { TmIdToNIdVH.
AddKey(TmId); }
 
  809   TmBucketV.
Gen(TmIdNIdVV.
Len());
 
  810   for (
int i = 0; i < TmIdNIdVV.
Len(); i++) {
 
  812     Bucket.
BegTm = TmIdNIdVV[i].Val1;
 
  813     Bucket.
NIdV = TmIdNIdVV[i].Val2;
 
  820   for (
int e = 0; e < EIdV.
Len(); e++) {
 
  822     if (! TmIdToEIdVH.
IsKey(TmId)) { TmIdToEIdVH.
AddKey(TmId); }
 
  828   TmBucketV.
Gen(TmIdEIdVV.
Len());
 
  829   for (
int i = 0; i < TmIdEIdVV.
Len(); i++) {
 
  831     Bucket.
BegTm = TmIdEIdVV[i].Val1;
 
  832     Bucket.
NIdV = TmIdEIdVV[i].Val2;
 
  838   TmBucketV.
Gen(NIdV.
Len() / NodesPerBucket + 1, 0);
 
  839   for (
int i = 0; i < NIdV.
Len(); i++) {
 
  840     const int b = i/NodesPerBucket;
 
  842     TmBucketV[b].NIdV.
Add(NIdV[i]);
 
  848   TmBucketV.
Gen(EIdV.
Len()/EdgesPerBucket + 1, 0);
 
  849   for (
int i = 0; i < EIdV.
Len(); i++) {
 
  850     const int b = i/EdgesPerBucket;
 
  852     TmBucketV[b].NIdV.
Add(EIdV[i]);
 
  864     const int Src = EI.GetSrcNId();
 
  865     const int Dst = EI.GetDstNId();
 
  866     if (Src==Dst || Graph->
IsEdge(Src, Dst)) { 
continue; } 
 
  871     if (edge % 10000 == 0) {
 
  872       printf(
"\redges %dk / %dk: triangle edges: %dk [total %s]", edge/1000, EIdV.
Len()/1000,
 
  885   for (
int t = 0; t < TmBucketV.
Len(); t++) {
 
  886     EdgeIdV.
AddV(TmBucketV[t].NIdV); 
 
  887     printf(
"\n***%d/%d: %s (%d edges) ", t+1, TmBucketV.
Len(), TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.
Len());  ExeTm.
Tick();
 
  888     if (TmBucketV[t].BegTm < StartTm) { 
continue; }
 
  890     GStatVec->Add(PreGraph, TmBucketV[t].BegTm);
 
  891     printf(
"  [%s]\n", ExeTm.
GetTmStr());
 
  899                             const TTmUnit& TmUnit, 
const int& TakeNTmUnits, 
const bool& LinkBWays)
 const {
 
  906   for (
int t = 0; t < TmBucketV.
Len(); t++) {
 
  908     if (TakeNTmUnits == -1) {
 
  909       EdgeIdV.
AddV(TmBucketV[t].NIdV); }
 
  911       if (t < TakeNTmUnits) { 
continue; }
 
  913       for (
int i = t-TakeNTmUnits; i < t; i++) { EdgeIdV.
AddV(TmBucketV[i].NIdV); }
 
  915     printf(
"*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.
Len());  ExeTm.
Tick();
 
  919       for (
TNEGraph::TEdgeI EI = PreGraph->BegEI(); EI < PreGraph->EndEI(); EI++) {
 
  920         if (PreGraph->IsEdge(EI.GetDstNId(), EI.GetSrcNId(), 
true)) { KeepEIdV.
Add(EI.GetId()); }
 
  925     GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
 
  927     GrowthStat->
Save(FOut); }
 
  928     GrowthStat->SaveTxt(FNmPref, Desc);
 
  929     printf(
"  [%s]\n", ExeTm.
GetTmStr());
 
  935                              const TSecTm& StartTm, 
const int& NDiamRuns, 
const bool& OnlyWcc)
 const {
 
  942   for (
int t = 0; t < TmBucketV.
Len(); t++) {
 
  943     EdgeIdV.
AddV(TmBucketV[t].NIdV); 
 
  944     printf(
"\n*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr(TmUnit).CStr(), EdgeIdV.
Len());  ExeTm.
Tick();
 
  945     if (TmBucketV[t].BegTm < StartTm) 
continue;
 
  946     PNGraph PreGraph = TSnap::ConvertESubGraph<PNGraph>(FullGraph, EdgeIdV);
 
  948     double EffDiam = 0.0;
 
  949     for (
int r = 0; r < NDiamRuns; r++) {
 
  950       printf(
"%d...", r+1);  Run1Tm.
Tick();
 
  954       printf(
"[%s]\r", Run1Tm.
GetTmStr());
 
  957     TmDiamV.
Add(
TFltTr(TmBucketV[t].BegTm.Round(TmUnit).GetAbsSecs(), Mom.GetMean(), Mom.GetSDev()));
 
  960     printf(
"  [%s]          \n", ExeTm.
GetTmStr());
 
  967     GnuPlot.
SetXYLabel(
"NODES", 
"AVERAGE "+WccStr+
"Effective Diameter");
 
  978                                  const TSecTm& DelPreTmEdges, 
const TSecTm& PostTmDiam, 
const bool& LinkBWays) {
 
  979   printf(
"\nGrowth over time: degree distribution, Growth Power Law, Diameter.\n  %s group by %s.\n",
 
  981   printf(
"  Delete out-edges of pre time %s nodes.\n  Take subgraph of post year %s subgraph.\n\n",
 
 1227   printf(
"Generating G_nm(%d, %d)\n", Nodes, Edges);
 
 1230   Net->Reserve(Nodes, Edges);
 
 1231   for (
int e = 0; e < Edges; e++) {
 
 1234     while (Dst == Src || Net->IsEdge(Src, Dst)) {
 
 1236     if (! Net->IsNode(Src)) { Net->AddNode(Src, 
TSecTm(e)); }
 
 1237     if (! Net->IsNode(Dst)) { Net->AddNode(Dst, 
TSecTm(e)); }
 
 1238     Net->AddEdge(Src, Dst, -1, 
TSecTm(e));
 
 1245   const double Alpha = Nodes/double(Edges);
 
 1246   printf(
"Generating PA(%d, %d), with slope in:%.1f, out: %.1f\n", Nodes, Edges,
 
 1247     2+GammaIn/(Alpha/(1-Alpha)), 2+GammaOut/(Alpha/(1-Alpha)));
 
 1249   int nodes=0, edges=0, time=0, iter=0;
 
 1250   TIntV OutW(Edges, 0), InW(Edges, 0);
 
 1252   Net->Reserve(Nodes, Edges);
 
 1254   Net->AddNode(0, 
TSecTm(time++));  nodes++;
 
 1255   OutW.Add(0);  InW.
Add(0);
 
 1256   while (edges < Edges) {
 
 1257     int Src=-1, Dst=-1;  iter++;
 
 1259       if (nodes < Nodes) {
 
 1263       if (
TInt::Rnd.GetUniDev() < nodes*GammaIn/double(edges+nodes*GammaIn)) {
 
 1266       if (
TInt::Rnd.GetUniDev() < nodes*GammaOut/double(edges+nodes*GammaOut)) {
 
 1270     if (Src == Dst || Net->IsEdge(Src, Dst)) {
 
 1274     if (! Net->IsNode(Src)) { Net->AddNode(Src, 
TSecTm(time++)); nodes++; }
 
 1275     if (! Net->IsNode(Dst)) { Net->AddNode(Dst, 
TSecTm(time++)); nodes++; }
 
 1276     Net->AddEdge(Src, Dst, -1, 
TSecTm(time++));
 
 1277     OutW.Add(Src); InW.
Add(Dst); edges++;
 
 1279   for (
int node = 0; node < Nodes; node++) {
 
 1280     if (! Net->IsNode(node)) {
 
 1281       Net->AddNode(node, 
TSecTm(time++)); }
 
 1287   printf(
"Generating PA, nodes:%d, out-deg:%d\n", Nodes, OutDeg);
 
 1291   Net->Reserve(Nodes, OutDeg*Nodes);
 
 1292   Net->AddNode(0, 
TSecTm(++time));  Net->AddNode(1, 
TSecTm(++time));
 
 1293   Net->AddEdge(0, 1, -1, 
TSecTm(++time));
 
 1296   for (
int node = 2; node <= Nodes; node++) {
 
 1298     while (NodeSet.
Len() < OutDeg && NodeSet.
Len() < node) {
 
 1301     const int N = Net->AddNode(node, 
TSecTm(++time));
 
 1302     for (
int i = 0; i < NodeSet.
Len(); i++) {
 
 1303       Net->AddEdge(node, NodeSet[i], -1, 
TSecTm(++time));
 
 1304       NIdV.
Add(N);  NIdV.
Add(NodeSet[i]);
 
 1315   FILE *F = fopen(EdgeFNm.
CStr(), 
"wt");
 
 1318   for (
int e =0; e < EIdV.
Len(); e++) {
 
 1319     const TEdgeI EI = 
GetEI(EIdV[e]);
 
 1321       const int src = EI.GetSrcNId();
 
 1322       const int dst = EI.GetDstNId();
 
 1324       fprintf(F, 
"%d\t%d\t%d\n", NIdMap.
GetKeyId(src), NIdMap.
GetKeyId(dst), EI().GetAbsSecs()-BegTm);
 
 1326       fprintf(F, 
"%d\t%d\t%d\n", EI.GetSrcNId(), EI.GetDstNId(), EI().GetAbsSecs()-BegTm); }
 
 1333   for (
int i = 1; i <= 6; i++) {
 
 1334     Net->AddNode(i, 
TSecTm(0)); }
 
 1336   Net->AddEdge(1, 2, -1, 
TSecTm(tm++));
 
 1337   Net->AddEdge(3, 4, -1, 
TSecTm(tm++));
 
 1338   Net->AddEdge(3, 1, -1, 
TSecTm(tm++));
 
 1339   Net->AddEdge(5, 6, -1, 
TSecTm(tm++));
 
 1340   Net->AddEdge(6, 4, -1, 
TSecTm(tm++));
 
 1341   Net->AddEdge(5, 3, -1, 
TSecTm(tm++));
 
 1342   Net->AddEdge(5, 4, -1, 
TSecTm(tm++));
 
 1343   Net->AddEdge(5, 2, -1, 
TSecTm(tm++));
 
 1348   const int BegOfTm = 1047369600; 
 
 1350   printf(
"Adding nodes...");
 
 1353     const int NId = Ss.
GetInt(0);
 
 1354     const int Tm = Ss.
GetInt(1)+BegOfTm;
 
 1356       printf(
"  skip node %g (time %d)\n", (
double) Ss.
GetLineNo(), Ss.
GetInt(1)); 
continue; }
 
 1357     Net->AddNode(NId, 
TSecTm(Tm));
 
 1359   printf(
" %d nodes\n", Net->GetNodes());
 
 1360   printf(
"Adding edges...");
 
 1365     const int NId1 = Ss.
GetInt(0);
 
 1366     const int NId2 = Ss.
GetInt(1);
 
 1368     if (! Net->IsNode(NId1) || ! Net->IsNode(NId2)) { printf(
"not node\n"); 
continue; }
 
 1369     if (Tm < 
TSecTm(2002, 1, 1)) { SkipCnt++;
 
 1370       printf(
"  skip edge %g (time %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr()); 
continue; }
 
 1371     if (Tm+600 < Net->GetNDat(NId1)) {
 
 1372       printf(
"  1:skip edge %g (time %s < %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr(), Net->GetNDat(NId1).GetStr().CStr());
 
 1374       SkipCnt++;  
continue; }
 
 1375     if (Tm+600 < Net->GetNDat(NId2)) { SkipCnt++;
 
 1376       printf(
"  2:skip edge %g (time %s < %s)\n", (
double) Ss.
GetLineNo(), Tm.
GetStr().
CStr(), Net->GetNDat(NId2).GetStr().CStr());
 
 1378       SkipCnt++;  
continue; }
 
 1379     Net->AddEdge(NId1, NId2, -1, 
TSecTm(Tm));
 
 1382   printf(
"  %d edges\n", Net->GetEdges());
 
 1383   printf(
"  %d edges skipped (edge time < node time)\n", SkipCnt);
 
 1384   Net->UpdateNodeTimes();
 
 1391   printf(
"Loading %s\n", EdgeFNm.
CStr());
 
 1399     if (Ss.
IsCmt()) { 
continue; }
 
 1401     const char* Node1 = Ss.
GetFld(SrcFld);
 
 1402     const char* Node2 = Ss.
GetFld(DstFld);
 
 1403     const char* TmStr = Ss.
GetFld(TimeFld);
 
 1404     if (strcmp(TmStr,
"NULL")==0) { 
continue; }
 
 1406     const TSecTm Tm(atoi(TmStr));
 
 1407     const int NId1 = StrToId.
AddKey(Node1);
 
 1408     const int NId2 = StrToId.
AddKey(Node2);
 
 1409     if (! Net->IsNode(NId1)) { Net->AddNode(NId1, 
TSecTm()); }
 
 1410     if (! Net->IsNode(NId2)) { Net->AddNode(NId2, 
TSecTm()); }
 
 1413     Net->AddEdge(NId1, NId2, -1, Tm);
 
 1414     if (++LineCnt % 1000 == 0) {
 
 1415       printf(
"\r  %dk lines processed: %d %d [%s]", LineCnt/1000, Net->GetNodes(), Net->GetEdges(), ExeTm.
GetStr()); }
 
 1417   printf(
"\r  %d lines processed: %d %d [%s]\n", LineCnt, Net->GetNodes(), Net->GetEdges(), ExeTm.
GetStr());
 
 1418   printf(
"  Data range %s -- %s\n", MinTm.
GetStr().
CStr(), MaxTm.GetStr().CStr());
 
 1420   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 
 
virtual 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 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 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 
 
static void PlotValV(const TVec< TVal1 > &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)
 
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)