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
TTimeNENet Class Reference

#include <timenet.h>

Inherits TNodeEdgeNet< TSecTm, TSecTm >.

Public Types

typedef TNodeEdgeNet< TSecTm, TSecTmTNet
 
typedef TPt< TNodeEdgeNet< TSecTm, TSecTm > > PNet
 
- Public Types inherited from TNodeEdgeNet< TSecTm, TSecTm >
typedef TSecTm TNodeDat
 
typedef TSecTm TEdgeDat
 
typedef TNodeEdgeNet< TSecTm, TSecTmTNet
 
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)
 
int AddNodeUnchecked (int NId=-1)
 Adds a node of ID NId to the network, noop if the node already exists. 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. More...
 
static PNet Load (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it. More...
 
static PNet LoadShM (TShMIn &ShMIn)
 Static constructor that loads the network from memory. 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 761 of file timenet.cpp.

761  {
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; }
768  }
769  printf("Node times:\n %s\n %s\n", MnNodeTm.GetStr().CStr(), MxNodeTm.GetStr().CStr());
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; }
774  }
775  printf("Edge times:\n %s\n %s\n", MnEdgeTm.GetStr().CStr(), MxEdgeTm.GetStr().CStr());
776 }
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1389
bool IsDef() const
Definition: tm.h:123
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:1338
Definition: tm.h:81
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
char * CStr()
Definition: dt.h:479
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1391
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1340
PTimeNENet TTimeNENet::Get1stEdgeNet ( ) const

Definition at line 629 of file timenet.cpp.

629  {
630  PTimeNENet Net = TTimeNENet::New();
631  Net->Reserve(GetNodes(), -1);
632  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
633  Net->AddNode(NI.GetId(), NI.GetDat()); }
634  TIntV EIdV; GetEIdByTm(EIdV);
635  TIntPrSet EdgeSet(GetEdges());
636  for (int edge = 0; edge < EIdV.Len(); edge++) {
637  const TEdgeI EI = GetEI(EIdV[edge]);
638  const int Src = EI.GetSrcNId();
639  const int Dst = EI.GetDstNId();
640  if (Src==Dst || EdgeSet.IsKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)))) { continue; } // take only 1st edge
641  EdgeSet.AddKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)));
642  Net->AddEdge(EI);
643  }
644  return Net;
645 }
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:1338
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:788
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1307
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1393
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:1354
Definition: bd.h:196
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1340
void TTimeNENet::GetEdgeBuckets ( const int  EdgesPerBucket,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 846 of file timenet.cpp.

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

Definition at line 817 of file timenet.cpp.

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

Definition at line 788 of file timenet.cpp.

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

Definition at line 668 of file timenet.cpp.

668  {
669  PTimeNENet NewNetPt = TTimeNENet::New();
670  TTimeNENet& NewNet = *NewNetPt;
671  NewNet.Reserve(-1, EIdV.Len());
672  for (int edge = 0; edge < EIdV.Len(); edge++) {
673  const TEdgeI Edge = GetEI(EIdV[edge]);
674  if (! NewNet.IsNode(Edge.GetSrcNId()))
675  NewNet.AddNode(GetNI(Edge.GetSrcNId()));
676  if (! NewNet.IsNode(Edge.GetDstNId()))
677  NewNet.AddNode(GetNI(Edge.GetDstNId()));
678  NewNet.AddEdge(Edge);
679  }
680  NewNet.Defrag();
681  return NewNetPt;
682 }
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:1423
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1336
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1483
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1650
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1393
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:1557
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:1342
Definition: bd.h:196
PTimeNENet TTimeNENet::GetGnmRndNet ( const int &  Nodes,
const int &  Edges 
)
static

Definition at line 1226 of file timenet.cpp.

1226  {
1227  printf("Generating G_nm(%d, %d)\n", Nodes, Edges);
1228  int Src, Dst;
1229  PTimeNENet Net = TTimeNENet::New();
1230  Net->Reserve(Nodes, Edges);
1231  for (int e = 0; e < Edges; e++) {
1232  Src = TInt::Rnd.GetUniDevInt(Nodes);
1233  Dst = TInt::Rnd.GetUniDevInt(Nodes);
1234  while (Dst == Src || Net->IsEdge(Src, Dst)) {
1235  Dst = TInt::Rnd.GetUniDevInt(Nodes); }
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));
1239  }
1240  return Net;
1241 }
static TRnd Rnd
Definition: dt.h:1146
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 685 of file timenet.cpp.

685  {
686  PTimeNENet NewNetPt = TTimeNENet::New();
687  TTimeNENet& NewNet = *NewNetPt;
688  TSecTm PrevTm;
689  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
690  if (EI() > MaxEdgeTm) { break; }
691  if (! NewNet.IsNode(EI.GetSrcNId()))
692  NewNet.AddNode(GetNI(EI.GetSrcNId()));
693  if (! NewNet.IsNode(EI.GetDstNId()))
694  NewNet.AddNode(GetNI(EI.GetDstNId()));
695  NewNet.AddEdge(EI);
696  IAssert(! PrevTm.IsDef() || PrevTm <= EI()); // edge times must be sorted
697  PrevTm = EI();
698  }
699  NewNet.Defrag();
700  return NewNetPt;
701 }
#define IAssert(Cond)
Definition: bd.h:262
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:1389
bool IsDef() const
Definition: tm.h:123
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1336
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1483
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1650
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:1557
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:1342
Definition: bd.h:196
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:1391
void TTimeNENet::GetNIdByTm ( TIntV NIdV) const

Definition at line 778 of file timenet.cpp.

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

Definition at line 836 of file timenet.cpp.

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

Definition at line 1244 of file timenet.cpp.

1244  {
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)));
1248  // init
1249  int nodes=0, edges=0, time=0, iter=0;
1250  TIntV OutW(Edges, 0), InW(Edges, 0);
1251  PTimeNENet Net = TTimeNENet::New();
1252  Net->Reserve(Nodes, Edges);
1253  // 1st node
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++;
1258  if (TInt::Rnd.GetUniDev() < Alpha) {
1259  if (nodes < Nodes) {
1260  IAssert(Net->AddNode(nodes, TSecTm(time++)));
1261  nodes++; }
1262  } else {
1263  if (TInt::Rnd.GetUniDev() < nodes*GammaIn/double(edges+nodes*GammaIn)) {
1264  Src = TInt::Rnd.GetUniDevInt(nodes); }
1265  else { Src = OutW[TInt::Rnd.GetUniDevInt(OutW.Len())]; }
1266  if (TInt::Rnd.GetUniDev() < nodes*GammaOut/double(edges+nodes*GammaOut)) {
1267  Dst = TInt::Rnd.GetUniDevInt(nodes); }
1268  else { Dst = InW[TInt::Rnd.GetUniDevInt(InW.Len())]; }
1269  }
1270  if (Src == Dst || Net->IsEdge(Src, Dst)) {
1271  continue;
1272  }
1273  //printf("%d/%d %d %d\n", edges, iter, 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++;
1278  }
1279  for (int node = 0; node < Nodes; node++) {
1280  if (! Net->IsNode(node)) {
1281  Net->AddNode(node, TSecTm(time++)); }
1282  }
1283  return Net;
1284 }
#define IAssert(Cond)
Definition: bd.h:262
static TRnd Rnd
Definition: dt.h:1146
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 1286 of file timenet.cpp.

1286  {
1287  printf("Generating PA, nodes:%d, out-deg:%d\n", Nodes, OutDeg);
1288  // init
1289  int time=0;
1290  PTimeNENet Net = TTimeNENet::New();
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));
1294  TIntV NIdV; NIdV.Add(0); NIdV.Add(1);
1295  TIntSet NodeSet;
1296  for (int node = 2; node <= Nodes; node++) {
1297  NodeSet.Clr(false);
1298  while (NodeSet.Len() < OutDeg && NodeSet.Len() < node) {
1299  NodeSet.AddKey(NIdV[TInt::Rnd.GetUniDevInt(NIdV.Len())]);
1300  }
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]);
1305  }
1306  }
1307  return Net;
1308 }
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:575
static TRnd Rnd
Definition: dt.h:1146
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:602
PTimeNENet TTimeNENet::GetSmallNet ( )
static

Definition at line 1331 of file timenet.cpp.

1331  {
1332  PTimeNENet Net = TTimeNENet::New();
1333  for (int i = 1; i <= 6; i++) {
1334  Net->AddNode(i, TSecTm(0)); }
1335  int tm = 1;
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++));
1344  return Net;
1345 }
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 647 of file timenet.cpp.

647  {
648  PTimeNENet NewNetPt = TTimeNENet::New();
649  TTimeNENet& NewNet = *NewNetPt;
650  NewNet.Reserve(NIdV.Len(), -1);
651  int node, edge;
652  TNodeI NI;
653  for (node = 0; node < NIdV.Len(); node++) {
654  NewNet.AddNode(NIdV[node], GetNDat(NIdV[node]));
655  }
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())) {
661  NewNet.AddEdge(EI); }
662  }
663  }
664  NewNet.Defrag();
665  return NewNetPt;
666 }
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:1423
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1336
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:1483
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Definition: network.h:1346
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
Definition: network.h:1650
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1393
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:1557
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:1342
Definition: bd.h:196
PTimeNet TTimeNENet::GetTimeNet ( ) const

Definition at line 612 of file timenet.cpp.

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

Definition at line 798 of file timenet.cpp.

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

Definition at line 857 of file timenet.cpp.

857  {
858  PUNGraph Graph = TUNGraph::New(GetNodes(), GetEdges());
859  TIntV EIdV; GetEIdByTm(EIdV);
860  TriadEIdV.Clr();
861  TExeTm ExeTm;
862  for (int edge = 0; edge < EIdV.Len(); edge++) {
863  const TEdgeI EI = GetEI(EIdV[edge]);
864  const int Src = EI.GetSrcNId();
865  const int Dst = EI.GetDstNId();
866  if (Src==Dst || Graph->IsEdge(Src, Dst)) { continue; } // take only 1st edge
867  if (! Graph->IsNode(Src)) { Graph->AddNode(Src); }
868  if (! Graph->IsNode(Dst)) { Graph->AddNode(Dst); }
869  if (TSnap::GetCmnNbrs(Graph, Src, Dst) > 0) { TriadEIdV.Add(EIdV[edge]); }
870  Graph->AddEdge(Src, Dst);
871  if (edge % 10000 == 0) {
872  printf("\redges %dk / %dk: triangle edges: %dk [total %s]", edge/1000, EIdV.Len()/1000,
873  TriadEIdV.Len()/1000, ExeTm.GetStr()); }
874  }
875  return Graph->GetEdges();
876 }
Definition: tm.h:355
void GetEIdByTm(TIntV &EIdV) const
Definition: timenet.cpp:788
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1307
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
Definition: network.h:1393
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New().
Definition: graph.h:172
int GetEdges() const
Returns the number of edges in the network.
Definition: network.h:1354
Definition: bd.h:196
const char * GetStr() const
Definition: tm.h:368
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
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:708
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 1390 of file timenet.cpp.

1390  {
1391  printf("Loading %s\n", EdgeFNm.CStr());
1392  PTimeNENet Net = TTimeNENet::New();
1393  TStrHash<TInt> StrToId(Mega(1), true); // node id to string
1394  int LineCnt=0;
1395  TExeTm ExeTm;
1396  TSsParser Ss(EdgeFNm, Separator);
1397  TSecTm MinTm=TSecTm::GetCurTm(), MaxTm=TSecTm(100);
1398  while (Ss.Next()) {
1399  if (Ss.IsCmt()) { continue; }
1400  IAssert(Ss.Len() > TimeFld);
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; }
1405  //const TSecTm Tm = TSecTm::GetDtTmFromYmdHmsStr(TmStr);
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()); }
1411  MinTm=TMath::Mn(MinTm, Tm);
1412  MaxTm=TMath::Mx(MaxTm, Tm);
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()); }
1416  }
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());
1419  //TSnap::PrintInfo(Net, "", "", false);
1420  Net->UpdateNodeTimes();
1421  return Net;
1422 }
#define IAssert(Cond)
Definition: bd.h:262
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
Definition: tm.h:355
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:781
Definition: tm.h:81
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
static TSecTm GetCurTm()
Definition: tm.cpp:697
Definition: bd.h:196
const char * GetStr() const
Definition: tm.h:368
char * CStr()
Definition: dt.h:479
PTimeNENet TTimeNENet::LoadFlickr ( const TStr NodeFNm,
const TStr EdgeFNm 
)
static

Definition at line 1347 of file timenet.cpp.

1347  {
1348  const int BegOfTm = 1047369600; // Tue Mar 11 01:00:00 2003 (begining of Flickr)
1349  PTimeNENet Net = TTimeNENet::New();
1350  printf("Adding nodes...");
1351  { TSsParser Ss(NodeFNm, ssfWhiteSep);
1352  while (Ss.Next()) {
1353  const int NId = Ss.GetInt(0);
1354  const int Tm = Ss.GetInt(1)+BegOfTm;
1355  if (TSecTm(Tm) < TSecTm(2002, 1, 1)) {
1356  printf(" skip node %g (time %d)\n", (double) Ss.GetLineNo(), Ss.GetInt(1)); continue; }
1357  Net->AddNode(NId, TSecTm(Tm));
1358  } }
1359  printf(" %d nodes\n", Net->GetNodes());
1360  printf("Adding edges...");
1361  int SkipCnt=0;
1362  //TIntH SkipDiffCnt;
1363  { TSsParser Ss(EdgeFNm, ssfWhiteSep);
1364  while (Ss.Next()) {
1365  const int NId1 = Ss.GetInt(0);
1366  const int NId2 = Ss.GetInt(1);
1367  const TSecTm Tm = TSecTm(Ss.GetInt(2)+BegOfTm);
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());
1373  //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId1).GetAbsSecs()) += 1;
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());
1377  //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId2).GetAbsSecs()) += 1;
1378  SkipCnt++; continue; }
1379  Net->AddEdge(NId1, NId2, -1, TSecTm(Tm));
1380  } }
1381  //TGnuPlot::PlotValCntH(SkipDiffCnt, "flickr-edgeNodeDiff", "", "seconds", "count");
1382  printf(" %d edges\n", Net->GetEdges());
1383  printf(" %d edges skipped (edge time < node time)\n", SkipCnt);
1384  Net->UpdateNodeTimes();
1385  return Net;
1386 }
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:479
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 605 of file timenet.cpp.

605  {
606  if (this != &TimeNet) {
607  TNet::operator=(TimeNet);
608  }
609  return *this;
610 }
TNodeEdgeNet & operator=(const TNodeEdgeNet &Net)
Definition: network.h:1303
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 934 of file timenet.cpp.

935  {
936  TTimeNet::TTmBucketV TmBucketV;
937  GetEdgeTmBuckets(TmUnit, TmBucketV);
938  PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
939  TIntV EdgeIdV;
940  TExeTm ExeTm, Run1Tm;
941  TFltTrV TmDiamV, NdsDiamV;
942  for (int t = 0; t < TmBucketV.Len(); t++) {
943  EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
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);
947  TMom Mom;
948  double EffDiam = 0.0;
949  for (int r = 0; r < NDiamRuns; r++) {
950  printf("%d...", r+1); Run1Tm.Tick();
951  if (OnlyWcc) { EffDiam = TSnap::GetAnfEffDiam(TSnap::GetMxWcc(PreGraph)); }
952  else { EffDiam = TSnap::GetAnfEffDiam(PreGraph); }
953  Mom.Add(EffDiam);
954  printf("[%s]\r", Run1Tm.GetTmStr());
955  }
956  Mom.Def();
957  TmDiamV.Add(TFltTr(TmBucketV[t].BegTm.Round(TmUnit).GetAbsSecs(), Mom.GetMean(), Mom.GetSDev()));
958  NdsDiamV.Add(TFltTr(PreGraph->GetNodes(), Mom.GetMean(), Mom.GetSDev()));
959  NdsDiamV.Sort();
960  printf(" [%s] \n", ExeTm.GetTmStr());
961  const TStr WccStr = OnlyWcc ? "WCC " : TStr::GetNullStr();
962  { TGnuPlot GnuPlot("diamEff1."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
963  GnuPlot.SetXYLabel(TStr::Fmt("TIME [%s]", TTmInfo::GetTmUnitStr(TmUnit).CStr()), "AVERAGE "+WccStr+"Effective Diameter");
964  GnuPlot.AddErrBar(TmDiamV, "", "");
965  GnuPlot.SavePng(); }
966  { TGnuPlot GnuPlot("diamEff2."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
967  GnuPlot.SetXYLabel("NODES", "AVERAGE "+WccStr+"Effective Diameter");
968  GnuPlot.AddErrBar(NdsDiamV, "", "");
969  GnuPlot.SavePng(); }
970  }
971 }
Definition: tm.h:355
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:575
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1307
double GetAnfEffDiam(const PGraph &Graph, const bool &IsDir, const double &Percentile, const int &NApprox)
Definition: anf.h:216
Definition: xmath.h:129
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:817
const char * GetTmStr() const
Definition: tm.h:370
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1318
TTriple< TFlt, TFlt, TFlt > TFltTr
Definition: ds.h:181
static TStr GetNullStr()
Definition: dt.cpp:1626
void Tick()
Definition: tm.h:364
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:1354
Definition: bd.h:196
char * CStr()
Definition: dt.h:479
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
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:1110
void TTimeNENet::PlotMissingPast ( const TStr FNmPref,
const TStr Desc,
const TTmUnit TmUnit,
const TSecTm DelPreTmEdges,
const TSecTm PostTmDiam,
const bool &  LinkBWays 
)

Definition at line 977 of file timenet.cpp.

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

Definition at line 1310 of file timenet.cpp.

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

Definition at line 725 of file timenet.cpp.

725  {
726  int Cnt = 0;
727  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
728  if (NI.GetDeg() == 0) { continue; }
729  TSecTm NodeTm;
730  for (int edge = 0; edge < NI.GetOutDeg(); edge++) {
731  const TSecTm& EdgeTm = GetEDat(NI.GetOutEId(edge)); IAssert(EdgeTm.IsDef());
732  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
733  }
734  for (int edge = 0; edge < NI.GetInDeg(); edge++) {
735  const TSecTm& EdgeTm = GetEDat(NI.GetInEId(edge)); IAssert(EdgeTm.IsDef());
736  if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
737  }
738  GetNDat(NI.GetId()) = NodeTm;
739  }
740  printf("Node times set: %d/%d updates\n", Cnt, GetNodes());
741 }
#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:1338
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:1307
TSecTm & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
Definition: network.h:1346
TSecTm & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
Definition: network.h:1399
Definition: tm.h:81
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:1340
void TTimeNENet::SetRndEdgeTimes ( const int &  MinTmEdge = 0)

Definition at line 744 of file timenet.cpp.

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

Definition at line 703 of file timenet.cpp.

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

Definition at line 878 of file timenet.cpp.

878  {
879  TExeTm ExeTm;
880  PGStatVec GStatVec = TGStatVec::New(TimeStep, TakeStat);
881  TTimeNet::TTmBucketV TmBucketV;
882  GetEdgeTmBuckets(TimeStep, TmBucketV);
883  const PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
884  TIntV EdgeIdV;
885  for (int t = 0; t < TmBucketV.Len(); t++) {
886  EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
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; }
889  const PNEGraph PreGraph = TSnap::GetESubGraph(FullGraph, EdgeIdV);
890  GStatVec->Add(PreGraph, TmBucketV[t].BegTm);
891  printf(" [%s]\n", ExeTm.GetTmStr());
892  //{ TFOut FOut("LinkedIn.GStatVec"); GStatVec->Save(FOut); }
893  }
894  return GStatVec;
895 }
Definition: tm.h:355
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:817
const char * GetTmStr() const
Definition: tm.h:370
void Tick()
Definition: tm.h:364
Definition: bd.h:196
PGraph GetESubGraph(const PGraph &Graph, const TIntV &EIdV)
Returns a subgraph of graph Graph with EIdV edges.
Definition: subgraph.h:243
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:430
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:1110
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 898 of file timenet.cpp.

899  {
900  TGStat::NDiamRuns = NDiamRuns;
901  PGStatVec GrowthStat = TGStatVec::New(TmUnit, TakeStat);
902  TTimeNet::TTmBucketV TmBucketV;
903  GetEdgeTmBuckets(TmUnit, TmBucketV);
904  TIntV EdgeIdV;
905  TExeTm ExeTm;
906  for (int t = 0; t < TmBucketV.Len(); t++) {
907  // take graph over last TakeNTmUnits time units
908  if (TakeNTmUnits == -1) {
909  EdgeIdV.AddV(TmBucketV[t].NIdV); }
910  else {
911  if (t < TakeNTmUnits) { continue; }
912  EdgeIdV.Clr(false);
913  for (int i = t-TakeNTmUnits; i < t; i++) { EdgeIdV.AddV(TmBucketV[i].NIdV); }
914  }
915  printf("*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.Len()); ExeTm.Tick();
916  PNEGraph PreGraph = TSnap::ConvertESubGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this), EdgeIdV);
917  if (LinkBWays) {
918  TIntV KeepEIdV; // keep only nodes that have in- and out-links (send and receive email)
919  for (TNEGraph::TEdgeI EI = PreGraph->BegEI(); EI < PreGraph->EndEI(); EI++) {
920  if (PreGraph->IsEdge(EI.GetDstNId(), EI.GetSrcNId(), true)) { KeepEIdV.Add(EI.GetId()); }
921  }
922  PreGraph = TSnap::GetESubGraph(PreGraph, KeepEIdV);
923  }
924  // take statistics
925  GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
926  { TFOut FOut(TStr::Fmt("growth.%s.gStatVec", FNmPref.CStr()));
927  GrowthStat->Save(FOut); }
928  GrowthStat->SaveTxt(FNmPref, Desc);
929  printf(" [%s]\n", ExeTm.GetTmStr());
930  }
931  return GrowthStat;
932 }
Definition: tm.h:355
Definition: fl.h:319
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Edge iterator. Only forward iteration (operator++) is supported.
Definition: graph.h:766
void GetEdgeTmBuckets(const TTmUnit &GroupBy, TTimeNet::TTmBucketV &TmBucketV) const
Definition: timenet.cpp:817
const char * GetTmStr() const
Definition: tm.h:370
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
void Tick()
Definition: tm.h:364
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:243
char * CStr()
Definition: dt.h:479
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:602
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
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:1110
void TTimeNENet::UpdateNodeTimes ( )

Definition at line 709 of file timenet.cpp.

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

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: