SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TTimeNENet Class Reference

#include <timenet.h>

Inherits TNodeEdgeNet< TSecTm, TSecTm >.

Public Types

typedef TNodeEdgeNet< TSecTm,
TSecTm
TNet
 
typedef TPt< TNodeEdgeNet
< TSecTm, TSecTm > > 
PNet
 
- Public Types inherited from TNodeEdgeNet< TSecTm, TSecTm >
typedef TSecTm TNodeDat
 
typedef TSecTm TEdgeDat
 
typedef TNodeEdgeNet< TSecTm,
TSecTm
TNet
 
typedef TPt< TNetPNet
 

Public Member Functions

 TTimeNENet ()
 
 TTimeNENet (const int &Nodes, const int &Edges)
 
 TTimeNENet (TSIn &SIn)
 
 TTimeNENet (const TTimeNENet &TimeNet)
 
void Save (TSOut &SOut) const
 Saves the network to a (binary) stream SOut. More...
 
TTimeNENetoperator= (const TTimeNENet &TimeNet)
 
PTimeNet GetTimeNet () const
 
PTimeNENet Get1stEdgeNet () const
 
PTimeNENet GetSubGraph (const TIntV &NIdV) const
 
PTimeNENet GetESubGraph (const TIntV &EIdV) const
 
PTimeNENet GetGraphUpToTm (const TSecTm &MaxEdgeTm) const
 
void SortNodeEdgeTimes ()
 
void UpdateNodeTimes ()
 
void SetNodeTmToFirstEdgeTm ()
 
void SetRndEdgeTimes (const int &MinTmEdge=0)
 
void DumpTimeStat () const
 
void GetNIdByTm (TIntV &NIdV) const
 
void GetEIdByTm (TIntV &EIdV) const
 
void GetTmBuckets (const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
 
void GetEdgeTmBuckets (const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
 
void GetNodeBuckets (const int NodesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
 
void GetEdgeBuckets (const int EdgesPerBucket, TTimeNet::TTmBucketV &TmBucketV) const
 
int GetTriadEdges (TIntV &TriadEIdV) const
 
PGStatVec TimeGrowth (const TTmUnit &TimeStep, const TFSet &TakeStat, const TSecTm &StartTm=TSecTm(1)) const
 
PGStatVec TimeGrowth (const TStr &FNmPref, const TStr &Desc, const TFSet &TakeStat, const int &NDiamRuns, const TTmUnit &TmUnit, const int &TakeNTmUnits, const bool &LinkBWays) const
 
void PlotEffDiam (const TStr &FNmPref, const TStr &Desc, const TTmUnit &GroupBy, const TSecTm &StartTm, const int &NDiamRuns=10, const bool &OnlyWcc=false) const
 
void PlotMissingPast (const TStr &FNmPref, const TStr &Desc, const TTmUnit &TmUnit, const TSecTm &DelPreTmEdges, const TSecTm &PostTmDiam, const bool &LinkBWays)
 
void SaveEdgeTm (const TStr &EdgeFNm, const bool &RenumberNId=false, const bool &RelativeTm=false) const
 
- Public Member Functions inherited from TNodeEdgeNet< TSecTm, TSecTm >
 TNodeEdgeNet ()
 
 TNodeEdgeNet (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. More...
 
 TNodeEdgeNet (const TNodeEdgeNet &Net)
 
 TNodeEdgeNet (TSIn &SIn)
 Constructor that loads the network from a (binary) stream SIn. More...
 
virtual ~TNodeEdgeNet ()
 
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the network (see the TGraphFlag for flags). More...
 
TNodeEdgeNetoperator= (const TNodeEdgeNet &Net)
 
int GetNodes () const
 Returns the number of nodes in the network. More...
 
int AddNode (int NId=-1)
 Adds a node of ID NId to the network. More...
 
int AddNode (int NId, const TSecTm &NodeDat)
 Adds node data to node with ID NId. More...
 
int AddNode (const TNodeI &NodeI)
 Adds a node NodeI and its node data to the network. More...
 
void DelNode (const int &NId)
 Deletes node of ID NId from the network. More...
 
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the network. More...
 
bool IsNode (const int &NId) const
 Tests whether ID NId is a node. More...
 
TNodeI BegNI () const
 Returns an iterator referring to the first node in the network. More...
 
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the network. More...
 
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the network. More...
 
void SetNDat (const int &NId, const TSecTm &NodeDat)
 Sets node data for the node of ID NId in the network. More...
 
TSecTmGetNDat (const int &NId)
 Returns node data for the node of ID NId in the network. More...
 
const TSecTmGetNDat (const int &NId) const
 Returns node data for the node of ID NId in the network. More...
 
int GetMxNId () const
 Returns an ID that is larger than any node ID in the network. More...
 
int GetEdges () const
 Returns the number of edges in the network. More...
 
int GetUniqEdges (const bool &IsDir=true) const
 Returns the number of edges in the network with a unique pair of nodes. More...
 
int AddEdge (const int &SrcNId, const int &DstNId, int EId=-1)
 Adds an edge between node IDs SrcNId and DstNId to the graph. More...
 
int AddEdge (const int &SrcNId, const int &DstNId, int EId, const TSecTm &EdgeDat)
 Adds an edge and edge data from node IDs SrcNId to node DstNId. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network. More...
 
void DelEdge (const int &EId)
 Deletes an edge with ID EId from the network. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes an edge from node IDs SrcNId to DstNId from the network. More...
 
bool IsEdge (const int &EId) const
 Tests whether an edge with ID EId exists in the network. More...
 
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. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const
 Tests whether an edge from node IDs SrcNId to DstNId with edge ID EId exists in the network. More...
 
int GetEId (const int &SrcNId, const int &DstNId) const
 
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the network. More...
 
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the network. More...
 
TEdgeI GetEI (const int &EId) const
 Not supported/implemented! More...
 
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
 Returns an iterator referring to edge (SrcNId, DstNId) in the graph. More...
 
void SetEDat (const int &EId, const TSecTm &EdgeDat)
 Sets edge data for the edge of ID NId in the network. More...
 
TSecTmGetEDat (const int &EId)
 Returns edge data for the edge with ID EId. More...
 
const TSecTmGetEDat (const int &EId) const
 Returns edge data for the edge with ID EId. More...
 
void SetAllEDat (const TSecTm &EdgeDat)
 Sets edge data for all the edges in the network to EDat. More...
 
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the network. More...
 
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the network. More...
 
int GetRndEId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random edge in the network. More...
 
TEdgeI GetRndEI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random edge in the network. More...
 
void GetNIdV (TIntV &NIdV) const
 Returns a vector of all node IDs in the network. More...
 
void GetEIdV (TIntV &EIdV) const
 Returns a vector of all edge IDs in the network. More...
 
bool Empty () const
 Tests whether the network is empty (has zero nodes). More...
 
void Clr ()
 Deletes all nodes and edges from the network. More...
 
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a network of Nodes nodes and Edges edges. More...
 
void SortNIdById (const bool &Asc=true)
 Sorts nodes by node IDs. More...
 
void SortNIdByDat (const bool &Asc=true)
 Sorts nodes by node data. More...
 
void SortEIdById (const bool &Asc=true)
 Sorts edges by edge IDs. More...
 
void SortEIdByDat (const bool &Asc=true)
 Sorts edges by edge data. More...
 
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the network. More...
 
bool IsOk (const bool &ThrowExcept=true) const
 Checks the network data structure for internal consistency. More...
 

Static Public Member Functions

static PTimeNENet New ()
 
static PTimeNENet New (const int &Nodes, const int &Edges)
 
static PTimeNENet Load (TSIn &SIn)
 
static PTimeNENet GetSmallNet ()
 
static PTimeNENet GetGnmRndNet (const int &Nodes, const int &Edges)
 
static PTimeNENet GetPrefAttach (const int &Nodes, const int &Edges, const double &GammaIn, const double &GammaOut)
 
static PTimeNENet GetPrefAttach (const int &Nodes, const int &OutDeg)
 
static PTimeNENet LoadFlickr (const TStr &NodeFNm, const TStr &EdgeFNm)
 
static PTimeNENet LoadEdgeTm (const TStr &EdgeFNm, const int &SrcFld=0, const int &DstFld=1, const int &TimeFld=2, const TSsFmt &Separator=ssfTabSep)
 
- Static Public Member Functions inherited from TNodeEdgeNet< TSecTm, TSecTm >
static PNet New ()
 Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New(). More...
 
static PNet Load (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it. More...
 

Friends

class TPt< TTimeNENet >
 

Additional Inherited Members

- Protected Attributes inherited from TNodeEdgeNet< TSecTm, TSecTm >
TCRef CRef
 
TInt MxNId
 
TInt MxEId
 
THash< TInt, TNode > NodeH
 
THash< TInt, TEdge > EdgeH
 

Detailed Description

Definition at line 76 of file timenet.h.

Member Typedef Documentation

Definition at line 79 of file timenet.h.

Definition at line 78 of file timenet.h.

Constructor & Destructor Documentation

TTimeNENet::TTimeNENet ( )
inline

Definition at line 81 of file timenet.h.

81 { }
TTimeNENet::TTimeNENet ( const int &  Nodes,
const int &  Edges 
)
inline

Definition at line 82 of file timenet.h.

82 : TNet(Nodes, Edges) { }
TNodeEdgeNet< TSecTm, TSecTm > TNet
Definition: timenet.h:78
TTimeNENet::TTimeNENet ( TSIn SIn)
inline

Definition at line 83 of file timenet.h.

83 : TNet(SIn) { }
TNodeEdgeNet< TSecTm, TSecTm > TNet
Definition: timenet.h:78
TTimeNENet::TTimeNENet ( const TTimeNENet TimeNet)
inline

Definition at line 84 of file timenet.h.

84 : TNet(TimeNet) { }
TNodeEdgeNet< TSecTm, TSecTm > TNet
Definition: timenet.h:78

Member Function Documentation

void TTimeNENet::DumpTimeStat ( ) const

Definition at line 759 of file timenet.cpp.

759  {
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; }
766  }
767  printf("Node times:\n %s\n %s\n", MnNodeTm.GetStr().CStr(), MxNodeTm.GetStr().CStr());
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; }
772  }
773  printf("Edge times:\n %s\n %s\n", MnEdgeTm.GetStr().CStr(), MxEdgeTm.GetStr().CStr());
774 }
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1247
bool IsDef() const
Definition: tm.h:123
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
Definition: tm.h:81
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
char * CStr()
Definition: dt.h:476
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1249
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198
PTimeNENet TTimeNENet::Get1stEdgeNet ( ) const

Definition at line 627 of file timenet.cpp.

627  {
628  PTimeNENet Net = TTimeNENet::New();
629  Net->Reserve(GetNodes(), -1);
630  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
631  Net->AddNode(NI.GetId(), NI.GetDat()); }
632  TIntV EIdV; GetEIdByTm(EIdV);
633  TIntPrSet EdgeSet(GetEdges());
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();
638  if (Src==Dst || EdgeSet.IsKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)))) { continue; } // take only 1st edge
639  EdgeSet.AddKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)));
640  Net->AddEdge(EI);
641  }
642  return Net;
643 }
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1251
static PTimeNENet New()
Definition: timenet.h:86
Definition: ds.h:32
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1212
Definition: bd.h:196
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198
void TTimeNENet::GetEdgeBuckets ( const int  EdgesPerBucket,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 844 of file timenet.cpp.

844  {
845  TIntV EIdV; GetEIdByTm(EIdV);
846  TmBucketV.Gen(EIdV.Len()/EdgesPerBucket + 1, 0);
847  for (int i = 0; i < EIdV.Len(); i++) {
848  const int b = i/EdgesPerBucket;
849  if (TmBucketV.Len() <= b) { TmBucketV.Add(TTimeNet::TTmBucket(TSecTm(b))); }
850  TmBucketV[b].NIdV.Add(EIdV[i]);
851  }
852 }
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
Definition: tm.h:81
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TTimeNENet::GetEdgeTmBuckets ( const TTmUnit GroupBy,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 815 of file timenet.cpp.

815  {
816  THash<TInt, TIntV> TmIdToEIdVH;
817  TIntV EIdV; GetEIdByTm(EIdV);
818  for (int e = 0; e < EIdV.Len(); e++) {
819  const int TmId = GetEDat(EIdV[e]).Round(TmUnit).GetAbsSecs();
820  if (! TmIdToEIdVH.IsKey(TmId)) { TmIdToEIdVH.AddKey(TmId); }
821  TmIdToEIdVH.GetDat(TmId).Add(EIdV[e]);
822  }
823  TVec<TPair<TInt, TIntV> > TmIdEIdVV;
824  TmIdToEIdVH.GetKeyDatPrV(TmIdEIdVV);
825  TmIdEIdVV.Sort();
826  TmBucketV.Gen(TmIdEIdVV.Len());
827  for (int i = 0; i < TmIdEIdVV.Len(); i++) {
828  TTimeNet::TTmBucket& Bucket = TmBucketV[i];
829  Bucket.BegTm = TmIdEIdVV[i].Val1;
830  Bucket.NIdV = TmIdEIdVV[i].Val2;
831  }
832 }
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
uint GetAbsSecs() const
Definition: tm.h:149
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1257
int AddKey(const TKey &Key)
Definition: hash.h:327
void GetKeyDatPrV(TVec< TPair< TKey, TDat > > &KeyDatPrV) const
Definition: hash.h:454
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TSecTm Round(const TTmUnit &TmUnit) const
Definition: tm.cpp:620
void TTimeNENet::GetEIdByTm ( TIntV EIdV) const

Definition at line 786 of file timenet.cpp.

786  {
787  TVec<TKeyDat<TSecTm, TInt> > TmToEIdV(GetEdges(), 0);
788  for (TEdgeI EI= BegEI(); EI < EndEI(); EI++) {
789  TmToEIdV.Add(TKeyDat<TSecTm, TInt>(EI.GetDat(), EI.GetId())); }
790  TmToEIdV.Sort();
791  EIdV.Gen(GetEdges(), 0);
792  for (int i = 0; i < TmToEIdV.Len(); i++) {
793  EIdV.Add(TmToEIdV[i].Dat); }
794 }
Definition: ds.h:336
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1247
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1212
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1249
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
PTimeNENet TTimeNENet::GetESubGraph ( const TIntV EIdV) const

Definition at line 666 of file timenet.cpp.

666  {
667  PTimeNENet NewNetPt = TTimeNENet::New();
668  TTimeNENet& NewNet = *NewNetPt;
669  NewNet.Reserve(-1, EIdV.Len());
670  for (int edge = 0; edge < EIdV.Len(); edge++) {
671  const TEdgeI Edge = GetEI(EIdV[edge]);
672  if (! NewNet.IsNode(Edge.GetSrcNId()))
673  NewNet.AddNode(GetNI(Edge.GetSrcNId()));
674  if (! NewNet.IsNode(Edge.GetDstNId()))
675  NewNet.AddNode(GetNI(Edge.GetDstNId()));
676  NewNet.AddEdge(Edge);
677  }
678  NewNet.Defrag();
679  return NewNetPt;
680 }
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:1281
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1194
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1341
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1496
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1251
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge between node IDs SrcNId and DstNId to the graph.
Definition: network.h:1403
static PTimeNENet New()
Definition: timenet.h:86
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:1200
Definition: bd.h:196
PTimeNENet TTimeNENet::GetGnmRndNet ( const int &  Nodes,
const int &  Edges 
)
static

Definition at line 1224 of file timenet.cpp.

1224  {
1225  printf("Generating G_nm(%d, %d)\n", Nodes, Edges);
1226  int Src, Dst;
1227  PTimeNENet Net = TTimeNENet::New();
1228  Net->Reserve(Nodes, Edges);
1229  for (int e = 0; e < Edges; e++) {
1230  Src = TInt::Rnd.GetUniDevInt(Nodes);
1231  Dst = TInt::Rnd.GetUniDevInt(Nodes);
1232  while (Dst == Src || Net->IsEdge(Src, Dst)) {
1233  Dst = TInt::Rnd.GetUniDevInt(Nodes); }
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));
1237  }
1238  return Net;
1239 }
static TRnd Rnd
Definition: dt.h:1051
static PTimeNENet New()
Definition: timenet.h:86
Definition: tm.h:81
Definition: bd.h:196
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39
PTimeNENet TTimeNENet::GetGraphUpToTm ( const TSecTm MaxEdgeTm) const

Definition at line 683 of file timenet.cpp.

683  {
684  PTimeNENet NewNetPt = TTimeNENet::New();
685  TTimeNENet& NewNet = *NewNetPt;
686  TSecTm PrevTm;
687  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
688  if (EI() > MaxEdgeTm) { break; }
689  if (! NewNet.IsNode(EI.GetSrcNId()))
690  NewNet.AddNode(GetNI(EI.GetSrcNId()));
691  if (! NewNet.IsNode(EI.GetDstNId()))
692  NewNet.AddNode(GetNI(EI.GetDstNId()));
693  NewNet.AddEdge(EI);
694  IAssert(! PrevTm.IsDef() || PrevTm <= EI()); // edge times must be sorted
695  PrevTm = EI();
696  }
697  NewNet.Defrag();
698  return NewNetPt;
699 }
#define IAssert(Cond)
Definition: bd.h:262
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1247
bool IsDef() const
Definition: tm.h:123
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1194
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1341
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1496
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge between node IDs SrcNId and DstNId to the graph.
Definition: network.h:1403
static PTimeNENet New()
Definition: timenet.h:86
Definition: tm.h:81
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:1200
Definition: bd.h:196
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1249
void TTimeNENet::GetNIdByTm ( TIntV NIdV) const

Definition at line 776 of file timenet.cpp.

776  {
777  TVec<TKeyDat<TSecTm, TInt> > TmToNIdV(GetNodes(), 0);
778  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
779  TmToNIdV.Add(TKeyDat<TSecTm, TInt>(NodeI.GetDat(), NodeI.GetId())); }
780  TmToNIdV.Sort();
781  NIdV.Gen(GetNodes(), 0);
782  for (int i = 0; i < TmToNIdV.Len(); i++) {
783  NIdV.Add(TmToNIdV[i].Dat); }
784 }
Definition: ds.h:336
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
void TTimeNENet::GetNodeBuckets ( const int  NodesPerBucket,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 834 of file timenet.cpp.

834  {
835  TIntV NIdV; GetNIdByTm(NIdV);
836  TmBucketV.Gen(NIdV.Len() / NodesPerBucket + 1, 0);
837  for (int i = 0; i < NIdV.Len(); i++) {
838  const int b = i/NodesPerBucket;
839  if (TmBucketV.Len() <= b) { TmBucketV.Add(TTimeNet::TTmBucket(TSecTm(b))); }
840  TmBucketV[b].NIdV.Add(NIdV[i]);
841  }
842 }
void GetNIdByTm(TIntV &NIdV) const
Definition: timenet.cpp:776
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
Definition: tm.h:81
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
PTimeNENet TTimeNENet::GetPrefAttach ( const int &  Nodes,
const int &  Edges,
const double &  GammaIn,
const double &  GammaOut 
)
static

Definition at line 1242 of file timenet.cpp.

1242  {
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)));
1246  // init
1247  int nodes=0, edges=0, time=0, iter=0;
1248  TIntV OutW(Edges, 0), InW(Edges, 0);
1249  PTimeNENet Net = TTimeNENet::New();
1250  Net->Reserve(Nodes, Edges);
1251  // 1st node
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++;
1256  if (TInt::Rnd.GetUniDev() < Alpha) {
1257  if (nodes < Nodes) {
1258  IAssert(Net->AddNode(nodes, TSecTm(time++)));
1259  nodes++; }
1260  } else {
1261  if (TInt::Rnd.GetUniDev() < nodes*GammaIn/double(edges+nodes*GammaIn)) {
1262  Src = TInt::Rnd.GetUniDevInt(nodes); }
1263  else { Src = OutW[TInt::Rnd.GetUniDevInt(OutW.Len())]; }
1264  if (TInt::Rnd.GetUniDev() < nodes*GammaOut/double(edges+nodes*GammaOut)) {
1265  Dst = TInt::Rnd.GetUniDevInt(nodes); }
1266  else { Dst = InW[TInt::Rnd.GetUniDevInt(InW.Len())]; }
1267  }
1268  if (Src == Dst || Net->IsEdge(Src, Dst)) {
1269  continue;
1270  }
1271  //printf("%d/%d %d %d\n", edges, iter, 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++;
1276  }
1277  for (int node = 0; node < Nodes; node++) {
1278  if (! Net->IsNode(node)) {
1279  Net->AddNode(node, TSecTm(time++)); }
1280  }
1281  return Net;
1282 }
#define IAssert(Cond)
Definition: bd.h:262
static TRnd Rnd
Definition: dt.h:1051
static PTimeNENet New()
Definition: timenet.h:86
Definition: tm.h:81
Definition: bd.h:196
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39
PTimeNENet TTimeNENet::GetPrefAttach ( const int &  Nodes,
const int &  OutDeg 
)
static

Definition at line 1284 of file timenet.cpp.

1284  {
1285  printf("Generating PA, nodes:%d, out-deg:%d\n", Nodes, OutDeg);
1286  // init
1287  int time=0;
1288  PTimeNENet Net = TTimeNENet::New();
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));
1292  TIntV NIdV; NIdV.Add(0); NIdV.Add(1);
1293  TIntSet NodeSet;
1294  for (int node = 2; node <= Nodes; node++) {
1295  NodeSet.Clr(false);
1296  while (NodeSet.Len() < OutDeg && NodeSet.Len() < node) {
1297  NodeSet.AddKey(NIdV[TInt::Rnd.GetUniDevInt(NIdV.Len())]);
1298  }
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]);
1303  }
1304  }
1305  return Net;
1306 }
void Clr(const bool &DoDel=true, const int &NoDelLim=-1)
Definition: shash.h:1243
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
static TRnd Rnd
Definition: dt.h:1051
static PTimeNENet New()
Definition: timenet.h:86
int AddKey(const TKey &Key)
Definition: shash.h:1254
int Len() const
Definition: shash.h:1121
Definition: tm.h:81
Definition: bd.h:196
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
PTimeNENet TTimeNENet::GetSmallNet ( )
static

Definition at line 1329 of file timenet.cpp.

1329  {
1330  PTimeNENet Net = TTimeNENet::New();
1331  for (int i = 1; i <= 6; i++) {
1332  Net->AddNode(i, TSecTm(0)); }
1333  int tm = 1;
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++));
1342  return Net;
1343 }
static PTimeNENet New()
Definition: timenet.h:86
Definition: tm.h:81
Definition: bd.h:196
PTimeNENet TTimeNENet::GetSubGraph ( const TIntV NIdV) const

Definition at line 645 of file timenet.cpp.

645  {
646  PTimeNENet NewNetPt = TTimeNENet::New();
647  TTimeNENet& NewNet = *NewNetPt;
648  NewNet.Reserve(NIdV.Len(), -1);
649  int node, edge;
650  TNodeI NI;
651  for (node = 0; node < NIdV.Len(); node++) {
652  NewNet.AddNode(NIdV[node], GetNDat(NIdV[node]));
653  }
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())) {
659  NewNet.AddEdge(EI); }
660  }
661  }
662  NewNet.Defrag();
663  return NewNetPt;
664 }
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:1281
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1194
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1341
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Definition: network.h:1204
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1496
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1251
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge between node IDs SrcNId and DstNId to the graph.
Definition: network.h:1403
static PTimeNENet New()
Definition: timenet.h:86
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:1200
Definition: bd.h:196
PTimeNet TTimeNENet::GetTimeNet ( ) const

Definition at line 610 of file timenet.cpp.

610  {
611  PTimeNet NewNet = TTimeNet::New();
612  NewNet->Reserve(GetNodes(), -1);
613  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
614  NewNet->AddNode(NI.GetId(), NI.GetDat());
615  }
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); }
621  }
622  NewNet->Defrag();
623  return NewNet;
624 }
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1247
static PTimeNet New()
Definition: timenet.h:39
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
Definition: bd.h:196
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1249
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198
void TTimeNENet::GetTmBuckets ( const TTmUnit GroupBy,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 796 of file timenet.cpp.

796  {
797  THash<TInt, TIntV> TmIdToNIdVH;
798  TIntV NIdV; GetNIdByTm(NIdV);
799  for (int n = 0; n < NIdV.Len(); n++) {
800  const int TmId = GetNDat(NIdV[n]).Round(TmUnit).GetAbsSecs();
801  if (! TmIdToNIdVH.IsKey(TmId)) { TmIdToNIdVH.AddKey(TmId); }
802  TmIdToNIdVH.GetDat(TmId).Add(NIdV[n]);
803  }
804  TVec<TPair<TInt, TIntV> > TmIdNIdVV;
805  TmIdToNIdVH.GetKeyDatPrV(TmIdNIdVV);
806  TmIdNIdVV.Sort();
807  TmBucketV.Gen(TmIdNIdVV.Len());
808  for (int i = 0; i < TmIdNIdVV.Len(); i++) {
809  TTimeNet::TTmBucket& Bucket = TmBucketV[i];
810  Bucket.BegTm = TmIdNIdVV[i].Val1;
811  Bucket.NIdV = TmIdNIdVV[i].Val2;
812  }
813 }
void GetNIdByTm(TIntV &NIdV) const
Definition: timenet.cpp:776
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Definition: network.h:1204
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
uint GetAbsSecs() const
Definition: tm.h:149
int AddKey(const TKey &Key)
Definition: hash.h:327
void GetKeyDatPrV(TVec< TPair< TKey, TDat > > &KeyDatPrV) const
Definition: hash.h:454
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TSecTm Round(const TTmUnit &TmUnit) const
Definition: tm.cpp:620
int TTimeNENet::GetTriadEdges ( TIntV TriadEIdV) const

Definition at line 855 of file timenet.cpp.

855  {
856  PUNGraph Graph = TUNGraph::New(GetNodes(), GetEdges());
857  TIntV EIdV; GetEIdByTm(EIdV);
858  TriadEIdV.Clr();
859  TExeTm ExeTm;
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; } // take only 1st edge
865  if (! Graph->IsNode(Src)) { Graph->AddNode(Src); }
866  if (! Graph->IsNode(Dst)) { Graph->AddNode(Dst); }
867  if (TSnap::GetCmnNbrs(Graph, Src, Dst) > 0) { TriadEIdV.Add(EIdV[edge]); }
868  Graph->AddEdge(Src, Dst);
869  if (edge % 10000 == 0) {
870  printf("\redges %dk / %dk: triangle edges: %dk [total %s]", edge/1000, EIdV.Len()/1000,
871  TriadEIdV.Len()/1000, ExeTm.GetStr()); }
872  }
873  return Graph->GetEdges();
874 }
Definition: tm.h:354
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1251
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New().
Definition: graph.h:152
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1212
Definition: bd.h:196
const char * GetStr() const
Definition: tm.h:367
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
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.
Definition: triad.h:383
static PTimeNENet TTimeNENet::Load ( TSIn SIn)
inlinestatic

Definition at line 88 of file timenet.h.

88 { return new TTimeNENet(SIn); }
TTimeNENet()
Definition: timenet.h:81
PTimeNENet TTimeNENet::LoadEdgeTm ( const TStr EdgeFNm,
const int &  SrcFld = 0,
const int &  DstFld = 1,
const int &  TimeFld = 2,
const TSsFmt Separator = ssfTabSep 
)
static

Definition at line 1388 of file timenet.cpp.

1388  {
1389  printf("Loading %s\n", EdgeFNm.CStr());
1390  PTimeNENet Net = TTimeNENet::New();
1391  TStrHash<TInt> StrToId(Mega(1), true); // node id to string
1392  int LineCnt=0;
1393  TExeTm ExeTm;
1394  TSsParser Ss(EdgeFNm, Separator);
1395  TSecTm MinTm=TSecTm::GetCurTm(), MaxTm=TSecTm(100);
1396  while (Ss.Next()) {
1397  if (Ss.IsCmt()) { continue; }
1398  IAssert(Ss.Len() > TimeFld);
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; }
1403  //const TSecTm Tm = TSecTm::GetDtTmFromYmdHmsStr(TmStr);
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()); }
1409  MinTm=TMath::Mn(MinTm, Tm);
1410  MaxTm=TMath::Mx(MaxTm, Tm);
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()); }
1414  }
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());
1417  //TSnap::PrintInfo(Net, "", "", false);
1418  Net->UpdateNodeTimes();
1419  return Net;
1420 }
#define IAssert(Cond)
Definition: bd.h:262
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
Definition: tm.h:354
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
Definition: ss.h:72
static PTimeNENet New()
Definition: timenet.h:86
#define Mega(n)
Definition: gbase.h:4
Definition: hash.h:716
Definition: tm.h:81
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
static TSecTm GetCurTm()
Definition: tm.cpp:692
Definition: bd.h:196
const char * GetStr() const
Definition: tm.h:367
char * CStr()
Definition: dt.h:476
PTimeNENet TTimeNENet::LoadFlickr ( const TStr NodeFNm,
const TStr EdgeFNm 
)
static

Definition at line 1345 of file timenet.cpp.

1345  {
1346  const int BegOfTm = 1047369600; // Tue Mar 11 01:00:00 2003 (begining of Flickr)
1347  PTimeNENet Net = TTimeNENet::New();
1348  printf("Adding nodes...");
1349  { TSsParser Ss(NodeFNm, ssfWhiteSep);
1350  while (Ss.Next()) {
1351  const int NId = Ss.GetInt(0);
1352  const int Tm = Ss.GetInt(1)+BegOfTm;
1353  if (TSecTm(Tm) < TSecTm(2002, 1, 1)) {
1354  printf(" skip node %g (time %d)\n", (double) Ss.GetLineNo(), Ss.GetInt(1)); continue; }
1355  Net->AddNode(NId, TSecTm(Tm));
1356  } }
1357  printf(" %d nodes\n", Net->GetNodes());
1358  printf("Adding edges...");
1359  int SkipCnt=0;
1360  //TIntH SkipDiffCnt;
1361  { TSsParser Ss(EdgeFNm, ssfWhiteSep);
1362  while (Ss.Next()) {
1363  const int NId1 = Ss.GetInt(0);
1364  const int NId2 = Ss.GetInt(1);
1365  const TSecTm Tm = TSecTm(Ss.GetInt(2)+BegOfTm);
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());
1371  //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId1).GetAbsSecs()) += 1;
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());
1375  //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId2).GetAbsSecs()) += 1;
1376  SkipCnt++; continue; }
1377  Net->AddEdge(NId1, NId2, -1, TSecTm(Tm));
1378  } }
1379  //TGnuPlot::PlotValCntH(SkipDiffCnt, "flickr-edgeNodeDiff", "", "seconds", "count");
1380  printf(" %d edges\n", Net->GetEdges());
1381  printf(" %d edges skipped (edge time < node time)\n", SkipCnt);
1382  Net->UpdateNodeTimes();
1383  return Net;
1384 }
Definition: ss.h:72
static PTimeNENet New()
Definition: timenet.h:86
Whitespace (space or tab) separated.
Definition: ss.h:11
Definition: tm.h:81
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
Definition: bd.h:196
char * CStr()
Definition: dt.h:476
static PTimeNENet TTimeNENet::New ( )
inlinestatic

Definition at line 86 of file timenet.h.

86 { return new TTimeNENet(); }
TTimeNENet()
Definition: timenet.h:81
static PTimeNENet TTimeNENet::New ( const int &  Nodes,
const int &  Edges 
)
inlinestatic

Definition at line 87 of file timenet.h.

87 { return new TTimeNENet(Nodes, Edges); }
TTimeNENet()
Definition: timenet.h:81
TTimeNENet & TTimeNENet::operator= ( const TTimeNENet TimeNet)

Definition at line 603 of file timenet.cpp.

603  {
604  if (this != &TimeNet) {
605  TNet::operator=(TimeNet);
606  }
607  return *this;
608 }
TNodeEdgeNet & operator=(const TNodeEdgeNet &Net)
Definition: network.h:1168
void TTimeNENet::PlotEffDiam ( const TStr FNmPref,
const TStr Desc,
const TTmUnit GroupBy,
const TSecTm StartTm,
const int &  NDiamRuns = 10,
const bool &  OnlyWcc = false 
) const

Definition at line 932 of file timenet.cpp.

933  {
934  TTimeNet::TTmBucketV TmBucketV;
935  GetEdgeTmBuckets(TmUnit, TmBucketV);
936  PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
937  TIntV EdgeIdV;
938  TExeTm ExeTm, Run1Tm;
939  TFltTrV TmDiamV, NdsDiamV;
940  for (int t = 0; t < TmBucketV.Len(); t++) {
941  EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
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);
945  TMom Mom;
946  double EffDiam = 0.0;
947  for (int r = 0; r < NDiamRuns; r++) {
948  printf("%d...", r+1); Run1Tm.Tick();
949  if (OnlyWcc) { EffDiam = TSnap::GetAnfEffDiam(TSnap::GetMxWcc(PreGraph)); }
950  else { EffDiam = TSnap::GetAnfEffDiam(PreGraph); }
951  Mom.Add(EffDiam);
952  printf("[%s]\r", Run1Tm.GetTmStr());
953  }
954  Mom.Def();
955  TmDiamV.Add(TFltTr(TmBucketV[t].BegTm.Round(TmUnit).GetAbsSecs(), Mom.GetMean(), Mom.GetSDev()));
956  NdsDiamV.Add(TFltTr(PreGraph->GetNodes(), Mom.GetMean(), Mom.GetSDev()));
957  NdsDiamV.Sort();
958  printf(" [%s] \n", ExeTm.GetTmStr());
959  const TStr WccStr = OnlyWcc ? "WCC " : TStr::GetNullStr();
960  { TGnuPlot GnuPlot("diamEff1."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
961  GnuPlot.SetXYLabel(TStr::Fmt("TIME [%s]", TTmInfo::GetTmUnitStr(TmUnit).CStr()), "AVERAGE "+WccStr+"Effective Diameter");
962  GnuPlot.AddErrBar(TmDiamV, "", "");
963  GnuPlot.SavePng(); }
964  { TGnuPlot GnuPlot("diamEff2."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
965  GnuPlot.SetXYLabel("NODES", "AVERAGE "+WccStr+"Effective Diameter");
966  GnuPlot.AddErrBar(NdsDiamV, "", "");
967  GnuPlot.SavePng(); }
968  }
969 }
Definition: tm.h:354
PGraph GetMxWcc(const PGraph &Graph)
Returns a graph representing the largest weakly connected component on an input Graph.
Definition: cncom.h:452
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
double GetAnfEffDiam(const PGraph &Graph, const bool &IsDir, const double &Percentile, const int &NApprox)
Definition: anf.h:217
Definition: xmath.h:129
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:815
const char * GetTmStr() const
Definition: tm.h:369
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
TTriple< TFlt, TFlt, TFlt > TFltTr
Definition: ds.h:175
static TStr GetNullStr()
Definition: dt.cpp:1626
void Tick()
Definition: tm.h:363
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
Definition: tm.cpp:108
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1212
Definition: bd.h:196
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
TPt< TTimeNENet > PTimeNENet
Definition: timenet.h:11
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
Definition: ds.h:1020
void TTimeNENet::PlotMissingPast ( const TStr FNmPref,
const TStr Desc,
const TTmUnit TmUnit,
const TSecTm DelPreTmEdges,
const TSecTm PostTmDiam,
const bool &  LinkBWays 
)

Definition at line 975 of file timenet.cpp.

976  {
977  printf("\nGrowth over time: degree distribution, Growth Power Law, Diameter.\n %s group by %s.\n",
978  FNmPref.CStr(), TTmInfo::GetTmUnitStr(TmUnit).CStr());
979  printf(" Delete out-edges of pre time %s nodes.\n Take subgraph of post year %s subgraph.\n\n",
980  DelPreTmEdges.GetStr().CStr(), PostTmDiam.GetStr().CStr());
981  // run diameter
982  /*const int NSamples = 100;
983  const int NDiamRuns = 10;
984  // delete past
985  if (DelPreEdges != -1) {
986  TIntV EdgeIdV;
987  printf("Deleting pre-year %d edges\n", DelPreEdges);
988  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
989  if (EI().GetYear() < DelPreEdges) { EdgeIdV.Add(EI.GetId()); } }
990  for (int e = 0; e < EdgeIdV.Len(); e++) { DelEdge(EdgeIdV[e]); }
991  printf(" Deleted %d edges (out of %d edges total).\n", EdgeIdV.Len(), GetEdges());
992  }
993  PNEGraph FullGraph = GetNEGraph();
994  TSnap::DelZeroDegNodes(FullGraph);
995 
996  PGrowthStat GrowthStat = TGrowthStat::New(TmUnit, TGraphStat::AllStat());
997  TFltV PreDiamSDev, PreEffDiamSDev, WccDiamSDev, WccEffDiamSDev;
998  TIntV EdgeIdV;
999  TExeTm ExeTm;
1000  TTimeNet::TTmBucketV EdgeTmBucketV;
1001  GetEdgeTmBuckets(TmUnit, EdgeTmBucketV);
1002  for (int t = 0; t < EdgeTmBucketV.Len(); t++) {
1003  printf("\nGraph: %s (%d / %d) [%s]\n", EdgeTmBucketV[t].BegTm.GetTmStr().CStr(),
1004  t+1, EdgeTmBucketV.Len(), TExeTm::GetCurTm());
1005  // up-to-year subgraph
1006  EdgeIdV.AddV(EdgeTmBucketV[t].NIdV); // nodes up to time T
1007  if (EdgeTmBucketV[t].BegTm.GetYear() < PostYearDiam) continue;
1008 
1009  const PNEGraph PreNEGraph = EdgeBothWays ? FullGraph->GetEdgeSubGraph(EdgeIdV) : FullGraph;
1010  PNGraph PreGraph = PreNEGraph->GetBWayGraph();
1011  PNGraph WccGraph = TSnap::GetMxWcc(PreGraph);
1012 
1013  // find nodes that are not in missing past
1014  TIntV PostYearNIdV, WccPostYearNIdV;
1015  THash<TIntPr, TInt> PostYearEdgeH;
1016  for (TNEGraph::TEdgeI EI = PreNEGraph->BegEI(); EI < PreNEGraph->EndEI(); EI++) {
1017  if (GetEDat(EI.GetId()).GetYear() >= PostYearDiam) {
1018  PostYearEdgeH.AddKey(TIntPr(EI.GetSrcNId(), EI.GetDstNId())); }
1019  }
1020  TIntH PostYearNIdH;
1021  for (int i = 0; i < PostYearEdgeH.Len(); i++) {
1022  if ((! EdgeBothWays) || (EdgeBothWays && PostYearEdgeH.IsKey(TIntPr(PostYearEdgeH.GetKey(i).Val2, PostYearEdgeH.GetKey(i).Val1)))) { //reverse edge exists
1023  PostYearNIdH.AddKey(PostYearEdgeH.GetKey(i).Val1);
1024  PostYearNIdH.AddKey(PostYearEdgeH.GetKey(i).Val2);
1025  }
1026  }
1027  PostYearNIdH.GetKeyV(PostYearNIdV);
1028  for (int i = 0; i < PostYearNIdV.Len(); i++) {
1029  if (WccGraph->IsNode(PostYearNIdV[i])) {
1030  WccPostYearNIdV.Add(PostYearNIdV[i]); }
1031  }
1032 
1033  // diameter of PostYearDiam subgraph using whole graph (all edges)
1034  TMom PreDiamMom, PreEffDiamMom, WccDiamMom, WccEffDiamMom;
1035  for (int r = 0; r < NDiamRuns; r++) {
1036  if (! PostYearNIdV.Empty()) {
1037  PreDiamMom.Add(-1); //PreDiamMom.Add(TSnap::GetBfsFullDiam(PreGraph, NSamples, PostYearNIdV, false));
1038  PreEffDiamMom.Add(TSnap::GetBfsEffDiam(PreGraph, NSamples, PostYearNIdV, false));
1039  }
1040  if (! WccPostYearNIdV.Empty()) {
1041  //WccDiamMom.Add(TSnap::GetBfsFullDiam(WccGraph, NSamples, WccPostYearNIdV, false));
1042  //WccEffDiamMom.Add(TSnap::GetBfsEffDiam(WccGraph, NSamples, WccPostYearNIdV, false));
1043  WccDiamMom.Add(-1); WccEffDiamMom.Add(-1);
1044  }
1045  printf(" diam: %d [%s] %.2f\r", r+1, ExeTm.GetTmStr(), PreEffDiamMom.GetValV().Last().Val); ExeTm.Tick();
1046  }
1047  PreDiamMom.Def(); PreEffDiamMom.Def();
1048  WccDiamMom.Def(); WccEffDiamMom.Def();
1049  // save stat
1050  PGraphStat GraphStatPt = GrowthStat->Add(EdgeTmBucketV[t].BegTm);
1051  TGraphStat& GraphStat = *GraphStatPt;
1052  GraphStat.Nodes = PreGraph->GetNodes();
1053  GraphStat.NonZNodes = PreGraph->GetNodes() - TSnap::CntDegNodes<PNGraph>(PreGraph, 0);
1054  GraphStat.Srcs = GraphStat.Nodes - TSnap::CntOutDegNodes<PNGraph>(PreGraph, 0);
1055  GraphStat.Edges = PreGraph->GetEdges();
1056  GraphStat.WccNodes= WccGraph->GetNodes();
1057  GraphStat.WccEdges = WccGraph->GetEdges();
1058  GraphStat.FullDiam = PreDiamMom.GetMean(); // mean
1059  GraphStat.EffDiam = PreEffDiamMom.GetMean();
1060  GraphStat.FullWccDiam = WccDiamMom.GetMean();
1061  GraphStat.EffWccDiam = WccEffDiamMom.GetMean();
1062  GraphStat.FullDiamDev = PreDiamMom.GetSDev(); // variance
1063  GraphStat.EffDiamDev = PreEffDiamMom.GetSDev();
1064  GraphStat.FullWccDiamDev = WccDiamMom.GetSDev();
1065  GraphStat.EffWccDiamDev = WccEffDiamMom.GetSDev();
1066  { TFOut FOut("growth."+FNmPref+".bin");
1067  GrowthStat->Save(FOut); }
1068  const TStr BigDesc = TStr::Fmt("%s. MISSING PAST DIAMETER\nDelPreEdges\t%d\nPostYearDiam\t%d\n",
1069  Desc.CStr(), DelPreEdges, PostYearDiam);
1070  GrowthStat->SaveTxt(FNmPref, BigDesc);
1071  }
1072  // diameter plots
1073  GrowthStat->PlotDiam(FNmPref, Desc + TStr::Fmt(" MISSING PAST. DelPre:%d PostYear:%d.",
1074  DelPreEdges, PostYearDiam));
1075  */
1076 }
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
Definition: tm.cpp:108
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
char * CStr()
Definition: dt.h:476
void TTimeNENet::Save ( TSOut SOut) const
inlinevirtual

Saves the network to a (binary) stream SOut.

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 85 of file timenet.h.

85 { TNet::Save(SOut); }
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
Definition: network.h:1161
void TTimeNENet::SaveEdgeTm ( const TStr EdgeFNm,
const bool &  RenumberNId = false,
const bool &  RelativeTm = false 
) const

Definition at line 1308 of file timenet.cpp.

1308  {
1309  TIntV EIdV; GetEIdByTm(EIdV);
1310  const int BegTm = RelativeTm ? GetEDat(EIdV[0]).GetAbsSecs() : 0;
1311  TIntSet NIdMap;
1312  if (RenumberNId) { NIdMap.Gen(GetNodes()); }
1313  FILE *F = fopen(EdgeFNm.CStr(), "wt");
1314  //fprintf(F, "#Nodes\t%d\n#Edges\t%d\n", GetNodes(), GetEdges());
1315  //fprintf(F, "#<src>\t<dst>\t<time>\n");
1316  for (int e =0; e < EIdV.Len(); e++) {
1317  const TEdgeI EI = GetEI(EIdV[e]);
1318  if (RenumberNId) {
1319  const int src = EI.GetSrcNId();
1320  const int dst = EI.GetDstNId();
1321  NIdMap.AddKey(src); NIdMap.AddKey(dst);
1322  fprintf(F, "%d\t%d\t%d\n", NIdMap.GetKeyId(src), NIdMap.GetKeyId(dst), EI().GetAbsSecs()-BegTm);
1323  }else {
1324  fprintf(F, "%d\t%d\t%d\n", EI.GetSrcNId(), EI.GetDstNId(), EI().GetAbsSecs()-BegTm); }
1325  }
1326  fclose(F);
1327 }
int GetKeyId(const TKey &Key) const
Definition: shash.h:1328
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
void Gen(const int &ExpectVals)
Definition: shash.h:1115
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1251
uint GetAbsSecs() const
Definition: tm.h:149
int AddKey(const TKey &Key)
Definition: shash.h:1254
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1257
char * CStr()
Definition: dt.h:476
void TTimeNENet::SetNodeTmToFirstEdgeTm ( )

Definition at line 723 of file timenet.cpp.

723  {
724  int Cnt = 0;
725  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
726  if (NI.GetDeg() == 0) { continue; }
727  TSecTm NodeTm;
728  for (int edge = 0; edge < NI.GetOutDeg(); edge++) {
729  const TSecTm& EdgeTm = GetEDat(NI.GetOutEId(edge)); IAssert(EdgeTm.IsDef());
730  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
731  }
732  for (int edge = 0; edge < NI.GetInDeg(); edge++) {
733  const TSecTm& EdgeTm = GetEDat(NI.GetInEId(edge)); IAssert(EdgeTm.IsDef());
734  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
735  }
736  GetNDat(NI.GetId()) = NodeTm;
737  }
738  printf("Node times set: %d/%d updates\n", Cnt, GetNodes());
739 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Definition: network.h:1204
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1257
Definition: tm.h:81
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198
void TTimeNENet::SetRndEdgeTimes ( const int &  MinTmEdge = 0)

Definition at line 742 of file timenet.cpp.

742  {
743  printf("Shuffling last %d (%d%%) edge arrival times..\n", GetEdges()-MinTmEdge, int(100.0*(GetEdges()-MinTmEdge)/double(GetEdges())));
744  TIntV RndEIdV; GetEIdByTm(RndEIdV);
745  TIntV TrueEIdV = RndEIdV;
746  TSecTmV TrueTmV;
747  const int SwapLen = RndEIdV.Len()-MinTmEdge;
748  for (int R = 0; R < 10; R++) {
749  for (int i = MinTmEdge; i < RndEIdV.Len(); i++) {
750  RndEIdV.Swap(TInt::Rnd.GetUniDevInt(SwapLen)+MinTmEdge, TInt::Rnd.GetUniDevInt(SwapLen)+MinTmEdge); }
751  }
752  for (int e = 0; e < TrueEIdV.Len(); e++) {
753  TrueTmV.Add(GetEDat(TrueEIdV[e])); }
754  for (int e = 0; e < RndEIdV.Len(); e++) {
755  GetEDat(RndEIdV[e]) = TrueTmV[e]; }
756  UpdateNodeTimes();
757 }
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:786
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
static TRnd Rnd
Definition: dt.h:1051
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
Definition: ds.h:1011
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1257
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1212
void UpdateNodeTimes()
Definition: timenet.cpp:707
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TTimeNENet::SortNodeEdgeTimes ( )

Definition at line 701 of file timenet.cpp.

701  {
702  NodeH.SortByDat(true);
703  EdgeH.SortByDat(true);
704 }
THash< TInt, TNode > NodeH
Definition: network.h:1150
THash< TInt, TEdge > EdgeH
Definition: network.h:1151
void SortByDat(const bool &Asc=true)
Definition: hash.h:246
PGStatVec TTimeNENet::TimeGrowth ( const TTmUnit TimeStep,
const TFSet TakeStat,
const TSecTm StartTm = TSecTm(1) 
) const

Definition at line 876 of file timenet.cpp.

876  {
877  TExeTm ExeTm;
878  PGStatVec GStatVec = TGStatVec::New(TimeStep, TakeStat);
879  TTimeNet::TTmBucketV TmBucketV;
880  GetEdgeTmBuckets(TimeStep, TmBucketV);
881  const PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
882  TIntV EdgeIdV;
883  for (int t = 0; t < TmBucketV.Len(); t++) {
884  EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
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; }
887  const PNEGraph PreGraph = TSnap::GetESubGraph(FullGraph, EdgeIdV);
888  GStatVec->Add(PreGraph, TmBucketV[t].BegTm);
889  printf(" [%s]\n", ExeTm.GetTmStr());
890  //{ TFOut FOut("LinkedIn.GStatVec"); GStatVec->Save(FOut); }
891  }
892  return GStatVec;
893 }
Definition: tm.h:354
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:815
const char * GetTmStr() const
Definition: tm.h:369
void Tick()
Definition: tm.h:363
Definition: bd.h:196
PGraph GetESubGraph(const PGraph &Graph, const TIntV &EIdV)
Returns a subgraph of graph Graph with EIdV edges.
Definition: subgraph.h:206
static PGStatVec New(const TTmUnit &_TmUnit=tmu1Sec)
Definition: gstat.cpp:426
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
TPt< TTimeNENet > PTimeNENet
Definition: timenet.h:11
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
Definition: ds.h:1020
PGStatVec TTimeNENet::TimeGrowth ( const TStr FNmPref,
const TStr Desc,
const TFSet TakeStat,
const int &  NDiamRuns,
const TTmUnit TmUnit,
const int &  TakeNTmUnits,
const bool &  LinkBWays 
) const

Definition at line 896 of file timenet.cpp.

897  {
898  TGStat::NDiamRuns = NDiamRuns;
899  PGStatVec GrowthStat = TGStatVec::New(TmUnit, TakeStat);
900  TTimeNet::TTmBucketV TmBucketV;
901  GetEdgeTmBuckets(TmUnit, TmBucketV);
902  TIntV EdgeIdV;
903  TExeTm ExeTm;
904  for (int t = 0; t < TmBucketV.Len(); t++) {
905  // take graph over last TakeNTmUnits time units
906  if (TakeNTmUnits == -1) {
907  EdgeIdV.AddV(TmBucketV[t].NIdV); }
908  else {
909  if (t < TakeNTmUnits) { continue; }
910  EdgeIdV.Clr(false);
911  for (int i = t-TakeNTmUnits; i < t; i++) { EdgeIdV.AddV(TmBucketV[i].NIdV); }
912  }
913  printf("*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.Len()); ExeTm.Tick();
914  PNEGraph PreGraph = TSnap::ConvertESubGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this), EdgeIdV);
915  if (LinkBWays) {
916  TIntV KeepEIdV; // keep only nodes that have in- and out-links (send and receive email)
917  for (TNEGraph::TEdgeI EI = PreGraph->BegEI(); EI < PreGraph->EndEI(); EI++) {
918  if (PreGraph->IsEdge(EI.GetDstNId(), EI.GetSrcNId(), true)) { KeepEIdV.Add(EI.GetId()); }
919  }
920  PreGraph = TSnap::GetESubGraph(PreGraph, KeepEIdV);
921  }
922  // take statistics
923  GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
924  { TFOut FOut(TStr::Fmt("growth.%s.gStatVec", FNmPref.CStr()));
925  GrowthStat->Save(FOut); }
926  GrowthStat->SaveTxt(FNmPref, Desc);
927  printf(" [%s]\n", ExeTm.GetTmStr());
928  }
929  return GrowthStat;
930 }
Definition: tm.h:354
Definition: fl.h:319
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
Edge iterator. Only forward iteration (operator++) is supported.
Definition: graph.h:664
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:815
const char * GetTmStr() const
Definition: tm.h:369
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
void Tick()
Definition: tm.h:363
static int NDiamRuns
Definition: gstat.h:38
void Save(TSOut &SOut) const
Definition: xmlser.h:16
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
Definition: bd.h:196
PGraph GetESubGraph(const PGraph &Graph, const TIntV &EIdV)
Returns a subgraph of graph Graph with EIdV edges.
Definition: subgraph.h:206
char * CStr()
Definition: dt.h:476
static PGStatVec New(const TTmUnit &_TmUnit=tmu1Sec)
Definition: gstat.cpp:426
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
TPt< TTimeNENet > PTimeNENet
Definition: timenet.h:11
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
Definition: ds.h:1020
void TTimeNENet::UpdateNodeTimes ( )

Definition at line 707 of file timenet.cpp.

707  {
708  int Cnt = 0;
709  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
710  TSecTm& NodeTm = NI();
711  for (int edge = 0; edge < NI.GetOutDeg(); edge++) {
712  const TSecTm& EdgeTm = GetEDat(NI.GetOutEId(edge));
713  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
714  }
715  for (int edge = 0; edge < NI.GetInDeg(); edge++) {
716  const TSecTm& EdgeTm = GetEDat(NI.GetInEId(edge));
717  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
718  }
719  }
720  printf("Update node times: %d/%d updates\n", Cnt, GetNodes());
721 }
bool IsDef() const
Definition: tm.h:123
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1196
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1172
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1257
Definition: tm.h:81
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1198

Friends And Related Function Documentation

friend class TPt< TTimeNENet >
friend

Definition at line 127 of file timenet.h.


The documentation for this class was generated from the following files: