SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
timenet.h
Go to the documentation of this file.
1 // Forward declarations
3 class TGrowthStat;
5 class TGStatVec;
7 
8 class TTimeNet;
9 typedef TPt<TTimeNet> PTimeNet;
10 
11 class TTimeNENet;
13 
15 // Time Network
16 class TTimeNet : public TNodeNet<TSecTm> {
17 public:
20 public:
21  class TTmBucket {
22  public:
23  TSecTm BegTm; // start time of the bucket, end time is determined by GroupBy
25  public:
26  TTmBucket() { }
27  TTmBucket(const TSecTm& BucketTm) : BegTm(BucketTm) { }
28  TTmBucket(const TTmBucket& TmBucket) : BegTm(TmBucket.BegTm), NIdV(TmBucket.NIdV) { }
29  TTmBucket& operator = (const TTmBucket& TmBucket) { if (this!=&TmBucket) {
30  BegTm=TmBucket.BegTm; NIdV=TmBucket.NIdV; } return *this; }
31  };
33 public:
34  TTimeNet() { }
35  TTimeNet(const int& Nodes, const int& Edges) : TNet(Nodes, Edges) { }
36  TTimeNet(const TTimeNet& TimeNet) : TNet(TimeNet) { }
37  TTimeNet(TSIn& SIn) : TNet(SIn) { }
38  void Save(TSOut& SOut) const { TNet::Save(SOut); }
39  static PTimeNet New() { return new TTimeNet(); }
40  static PTimeNet New(const int& Nodes, const int& Edges) { return new TTimeNet(Nodes, Edges); }
41  static PTimeNet Load(TSIn& SIn) { return new TTimeNet(SIn); }
42  TTimeNet& operator = (const TTimeNet& TimeNet);
43 
44  PTimeNet GetSubGraph(const TIntV& NIdV) const;
45  PTimeNENet GetTimeNENet() const;
46 
47  void GetNIdByTm(TIntV& NIdV) const;
48  void GetTmBuckets(const TTmUnit& GroupBy, TTmBucketV& TmBucketV) const;
49  void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV& TmBucketV) const;
50 
51  PGStatVec TimeGrowth(const TTmUnit& TmUnit, const TFSet& TakeStat, const TSecTm& StartTm) const;
52  void PlotEffDiam(const TStr& FNmPref, const TStr& Desc, const TTmUnit& GroupBy, const TSecTm& StartTm,
53  const int& NDiamRuns=10, const bool& OnlyWcc=false, const bool& AlsoRewire=false) const;
54  void PlotMissingPast(const TStr& FNmPref, const TStr& Desc, const TTmUnit& GroupBy,
55  const TSecTm& DelPreTmEdges, const TSecTm& PostTmDiam) const;
56  void PlotCCfOverTm(const TStr& FNmPref, TStr Desc, const TTmUnit& TmUnit, const int& NodesBucket=-1) const;
57  void PlotMedianDegOverTm(const TStr& FNmPref, const TTmUnit& TmUnit, const int& NodesPerBucket=-1) const;
58 
59  // networks
60  static PTimeNet LoadBipartite(const TStr& InFNm);
61  static PTimeNet LoadArxiv(const TStr& PaperFNm, const TStr& CiteFNm);
62  static PTimeNet LoadPatents(const TStr& PatentFNm, const TStr& CiteFNm);
63  static PTimeNet LoadAmazon(const TStr& StlFNm);
64 
65  friend class TPt<TTimeNet>;
66 };
67 
68 // set flags
69 namespace TSnap {
70 template <> struct IsDirected<TTimeNet> { enum { Val = 1 }; };
71 template <> struct IsNodeDat<TTimeNet> { enum { Val = 1 }; };
72 }
73 
75 // Time Node-Edge Network
76 class TTimeNENet : public TNodeEdgeNet<TSecTm, TSecTm> {
77 public:
80 public:
81  TTimeNENet() { }
82  TTimeNENet(const int& Nodes, const int& Edges) : TNet(Nodes, Edges) { }
83  TTimeNENet(TSIn& SIn) : TNet(SIn) { }
84  TTimeNENet(const TTimeNENet& TimeNet) : TNet(TimeNet) { }
85  void Save(TSOut& SOut) const { TNet::Save(SOut); }
86  static PTimeNENet New() { return new TTimeNENet(); }
87  static PTimeNENet New(const int& Nodes, const int& Edges) { return new TTimeNENet(Nodes, Edges); }
88  static PTimeNENet Load(TSIn& SIn) { return new TTimeNENet(SIn); }
89  TTimeNENet& operator = (const TTimeNENet& TimeNet);
90 
91  PTimeNet GetTimeNet() const;
92  PTimeNENet Get1stEdgeNet() const;
93  PTimeNENet GetSubGraph(const TIntV& NIdV) const;
94  PTimeNENet GetESubGraph(const TIntV& EIdV) const;
95  PTimeNENet GetGraphUpToTm(const TSecTm& MaxEdgeTm) const;
96 
97  void SortNodeEdgeTimes();
98  void UpdateNodeTimes();
100  void SetRndEdgeTimes(const int& MinTmEdge=0);
101  void DumpTimeStat() const;
102 
103  void GetNIdByTm(TIntV& NIdV) const;
104  void GetEIdByTm(TIntV& EIdV) const;
105  void GetTmBuckets(const TTmUnit& GroupBy, TTimeNet::TTmBucketV& TmBucketV) const;
106  void GetEdgeTmBuckets(const TTmUnit& GroupBy, TTimeNet::TTmBucketV& TmBucketV) const;
107  void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV& TmBucketV) const;
108  void GetEdgeBuckets(const int EdgesPerBucket, TTimeNet::TTmBucketV& TmBucketV) const;
109  int GetTriadEdges(TIntV& TriadEIdV) const;
110 
111  PGStatVec TimeGrowth(const TTmUnit& TimeStep, const TFSet& TakeStat, const TSecTm& StartTm=TSecTm(1)) const;
112  PGStatVec TimeGrowth(const TStr& FNmPref, const TStr& Desc, const TFSet& TakeStat, const int& NDiamRuns,
113  const TTmUnit& TmUnit, const int& TakeNTmUnits, const bool& LinkBWays) const;
114  void PlotEffDiam(const TStr& FNmPref, const TStr& Desc, const TTmUnit& GroupBy, const TSecTm& StartTm,
115  const int& NDiamRuns=10, const bool& OnlyWcc=false) const;
116  void PlotMissingPast(const TStr& FNmPref, const TStr& Desc, const TTmUnit& TmUnit,
117  const TSecTm& DelPreTmEdges, const TSecTm& PostTmDiam, const bool& LinkBWays);
118 
119  void SaveEdgeTm(const TStr& EdgeFNm, const bool& RenumberNId=false, const bool& RelativeTm=false) const;
120  static PTimeNENet GetSmallNet();
121  static PTimeNENet GetGnmRndNet(const int& Nodes, const int& Edges);
122  static PTimeNENet GetPrefAttach(const int& Nodes, const int& Edges, const double& GammaIn, const double& GammaOut);
123  static PTimeNENet GetPrefAttach(const int& Nodes, const int& OutDeg);
124  static PTimeNENet LoadFlickr(const TStr& NodeFNm, const TStr& EdgeFNm);
125  static PTimeNENet LoadEdgeTm(const TStr& EdgeFNm, const int& SrcFld=0, const int& DstFld=1, const int& TimeFld=2, const TSsFmt& Separator=ssfTabSep);
126 
127  friend class TPt<TTimeNENet>;
128 };
129 
130 // set flags
131 namespace TSnap {
132 template <> struct IsMultiGraph<TTimeNENet> { enum { Val = 1 }; };
133 template <> struct IsDirected<TTimeNENet> { enum { Val = 1 }; };
134 template <> struct IsNodeDat<TTimeNENet> { enum { Val = 1 }; };
135 template <> struct IsEdgeDat<TTimeNENet> { enum { Val = 1 }; };
136 }
PTimeNENet GetTimeNENet() const
Definition: timenet.cpp:32
TTimeNet(TSIn &SIn)
Definition: timenet.h:37
Tests (at compile time) if the graph is a network with data on nodes.
Definition: gbase.h:32
Main namespace for all the Snap global entities.
Definition: alg.h:1
void PlotEffDiam(const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &StartTm, const int &NDiamRuns=10, const bool &OnlyWcc=false) const
Definition: timenet.cpp:934
TTimeNet(const TTimeNet &TimeNet)
Definition: timenet.h:36
static PTimeNet LoadArxiv(const TStr &PaperFNm, const TStr &CiteFNm)
Definition: timenet.cpp:383
static PTimeNENet GetSmallNet()
Definition: timenet.cpp:1331
static PTimeNet New()
Definition: timenet.h:39
TPt< TGStatVec > PGStatVec
Definition: timenet.h:5
TPt< TNodeEdgeNet< TSecTm, TSecTm > > PNet
Definition: timenet.h:79
PTimeNENet Get1stEdgeNet() const
Definition: timenet.cpp:629
void PlotMissingPast(const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &DelPreTmEdges, const TSecTm &PostTmDiam) const
Definition: timenet.cpp:169
Tests (at compile time) if the graph is directed.
Definition: gbase.h:28
void GetNIdByTm(TIntV &NIdV) const
Definition: timenet.cpp:778
TTimeNENet()
Definition: timenet.h:81
void PlotMissingPast(const TStr &FNmPref, const TStr &Desc, const TTmUnit &TmUnit, const TSecTm &DelPreTmEdges, const TSecTm &PostTmDiam, const bool &LinkBWays)
Definition: timenet.cpp:977
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:788
Definition: bits.h:119
void PlotCCfOverTm(const TStr &FNmPref, TStr Desc, const TTmUnit &TmUnit, const int &NodesBucket=-1) const
Definition: timenet.cpp:253
PGStatVec TimeGrowth(const TTmUnit &TimeStep, const TFSet &TakeStat, const TSecTm &StartTm=TSecTm(1)) const
Definition: timenet.cpp:878
void GetEdgeBuckets(const int EdgesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:846
void GetTmBuckets(const TTmUnit &GroupBy, TTmBucketV &TmBucketV) const
Definition: timenet.cpp:59
static PTimeNet LoadPatents(const TStr &PatentFNm, const TStr &CiteFNm)
Definition: timenet.cpp:480
TVec< TTmBucket > TTmBucketV
Definition: timenet.h:32
PTimeNENet GetGraphUpToTm(const TSecTm &MaxEdgeTm) const
Definition: timenet.cpp:685
Node Edge Network (directed multigraph, TNEGraph with data on nodes and edges).
Definition: network.h:1074
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
Definition: network.h:1284
Definition: fl.h:58
TSsFmt
Spread-Sheet Separator Format.
Definition: ss.h:5
static PTimeNENet New(const int &Nodes, const int &Edges)
Definition: timenet.h:87
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:817
static PTimeNENet LoadEdgeTm(const TStr &EdgeFNm, const int &SrcFld=0, const int &DstFld=1, const int &TimeFld=2, const TSsFmt &Separator=ssfTabSep)
Definition: timenet.cpp:1390
void SaveEdgeTm(const TStr &EdgeFNm, const bool &RenumberNId=false, const bool &RelativeTm=false) const
Definition: timenet.cpp:1310
Graph Statistics Sequence.
Definition: gstat.h:155
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
Definition: timenet.cpp:106
void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:836
TTimeNENet(TSIn &SIn)
Definition: timenet.h:83
TTimeNet()
Definition: timenet.h:34
static PTimeNet New(const int &Nodes, const int &Edges)
Definition: timenet.h:40
static PTimeNENet GetPrefAttach(const int &Nodes, const int &Edges, const double &GammaIn, const double &GammaOut)
Definition: timenet.cpp:1244
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
Definition: network.h:168
Tests (at compile time) if the graph is a network with data on edges.
Definition: gbase.h:34
TTmBucket & operator=(const TTmBucket &TmBucket)
Definition: timenet.h:29
TTimeNet(const int &Nodes, const int &Edges)
Definition: timenet.h:35
static PTimeNENet New()
Definition: timenet.h:86
void SetNodeTmToFirstEdgeTm()
Definition: timenet.cpp:725
Tests (at compile time) if the graph is a multigraph with multiple edges between the same nodes...
Definition: gbase.h:30
void DumpTimeStat() const
Definition: timenet.cpp:761
Tab separated.
Definition: ss.h:6
void SetRndEdgeTimes(const int &MinTmEdge=0)
Definition: timenet.cpp:744
PTimeNENet GetSubGraph(const TIntV &NIdV) const
Definition: timenet.cpp:647
void PlotMedianDegOverTm(const TStr &FNmPref, const TTmUnit &TmUnit, const int &NodesPerBucket=-1) const
Definition: timenet.cpp:302
Definition: fl.h:128
static PTimeNet LoadBipartite(const TStr &InFNm)
Definition: timenet.cpp:346
void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
Definition: timenet.h:38
static PTimeNENet LoadFlickr(const TStr &NodeFNm, const TStr &EdgeFNm)
Definition: timenet.cpp:1347
static PTimeNet Load(TSIn &SIn)
Definition: timenet.h:41
PTimeNENet GetESubGraph(const TIntV &EIdV) const
Definition: timenet.cpp:668
Definition: tm.h:81
void GetNodeBuckets(const int NodesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:77
static PTimeNENet GetGnmRndNet(const int &Nodes, const int &Edges)
Definition: timenet.cpp:1226
TTimeNENet & operator=(const TTimeNENet &TimeNet)
Definition: timenet.cpp:605
void GetNIdByTm(TIntV &NIdV) const
Definition: timenet.cpp:48
TNodeEdgeNet< TSecTm, TSecTm > TNet
Definition: timenet.h:78
Definition: dt.h:412
TPt< TNodeNet< TSecTm > > PNet
Definition: timenet.h:19
int GetTriadEdges(TIntV &TriadEIdV) const
Definition: timenet.cpp:857
void UpdateNodeTimes()
Definition: timenet.cpp:709
TTmBucket(const TSecTm &BucketTm)
Definition: timenet.h:27
void GetTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:798
Definition: bd.h:196
void SortNodeEdgeTimes()
Definition: timenet.cpp:703
TPt< TTimeNet > PTimeNet
Definition: timenet.h:8
PTimeNet GetTimeNet() const
Definition: timenet.cpp:612
TTimeNet & operator=(const TTimeNet &TimeNet)
Definition: timenet.cpp:3
void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
Definition: timenet.h:85
TTmUnit
Definition: tm.h:11
TTmBucket(const TTmBucket &TmBucket)
Definition: timenet.h:28
TTimeNENet(const int &Nodes, const int &Edges)
Definition: timenet.h:82
static PTimeNet LoadAmazon(const TStr &StlFNm)
Definition: timenet.cpp:563
PTimeNet GetSubGraph(const TIntV &NIdV) const
Definition: timenet.cpp:10
static PTimeNENet Load(TSIn &SIn)
Definition: timenet.h:88
TPt< TGrowthStat > PGrowthStat
Definition: timenet.h:3
TTimeNENet(const TTimeNENet &TimeNet)
Definition: timenet.h:84
PGStatVec TimeGrowth(const TTmUnit &TmUnit, const TFSet &TakeStat, const TSecTm &StartTm) const
Definition: timenet.cpp:88
Node Network (directed graph, TNGraph with data on nodes only).
Definition: network.h:17
TNodeNet< TSecTm > TNet
Definition: timenet.h:18
TPt< TTimeNENet > PTimeNENet
Definition: timenet.h:11