SNAP Library 2.0, Developer Reference  2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TTimeNENet Class Reference

#include <timenet.h>

Inheritance diagram for TTimeNENet:
Collaboration diagram for TTimeNENet:

List of all members.

Public Types

typedef TNodeEdgeNet< TSecTm,
TSecTm
TNet
typedef TPt< TNodeEdgeNet
< TSecTm, TSecTm > > 
PNet

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.
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

Static Public Member Functions

static PTimeNENet New ()
 Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New().
static PTimeNENet New (const int &Nodes, const int &Edges)
static PTimeNENet Load (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it.
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)

Friends

class TPt< TTimeNENet >

Detailed Description

Definition at line 76 of file timenet.h.


Member Typedef Documentation

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 79 of file timenet.h.

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 78 of file timenet.h.


Constructor & Destructor Documentation

TTimeNENet::TTimeNENet ( ) [inline]

Definition at line 81 of file timenet.h.

Referenced by Load(), and New().

{ }

Here is the caller graph for this function:

TTimeNENet::TTimeNENet ( const int &  Nodes,
const int &  Edges 
) [inline]

Definition at line 82 of file timenet.h.

: TNet(Nodes, Edges) { }
TTimeNENet::TTimeNENet ( TSIn SIn) [inline]

Definition at line 83 of file timenet.h.

: TNet(SIn) { }
TTimeNENet::TTimeNENet ( const TTimeNENet TimeNet) [inline]

Definition at line 84 of file timenet.h.

: TNet(TimeNet) { }

Member Function Documentation

void TTimeNENet::DumpTimeStat ( ) const

Definition at line 759 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::BegEI(), TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TStr::CStr(), TNodeEdgeNet< TSecTm, TSecTm >::EndEI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TSecTm::GetStr(), and TSecTm::IsDef().

                                    {
  TSecTm MnNodeTm, MxNodeTm;
  TSecTm MnEdgeTm, MxEdgeTm;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    const TSecTm NodeTm = NI();
    if (! MnNodeTm.IsDef() || MnNodeTm>NodeTm) { MnNodeTm = NodeTm; }
    if (! MxNodeTm.IsDef() || MxNodeTm<NodeTm) { MxNodeTm = NodeTm; }
  }
  printf("Node times:\n  %s\n  %s\n", MnNodeTm.GetStr().CStr(), MxNodeTm.GetStr().CStr());
  for (TEdgeI EI= BegEI(); EI < EndEI(); EI++) {
    const TSecTm EdgeTm = EI();
    if (! MnEdgeTm.IsDef() || MnEdgeTm>EdgeTm) { MnEdgeTm = EdgeTm; }
    if (! MxEdgeTm.IsDef() || MxEdgeTm<EdgeTm) { MxEdgeTm = EdgeTm; }
  }
  printf("Edge times:\n  %s\n  %s\n", MnEdgeTm.GetStr().CStr(), MxEdgeTm.GetStr().CStr());
}

Here is the call graph for this function:

Definition at line 627 of file timenet.cpp.

References THashSet< TKey, THashFunc >::AddKey(), TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), GetEIdByTm(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), THashSet< TKey, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), TMath::Mx(), and New().

                                           {
  PTimeNENet Net = TTimeNENet::New();
  Net->Reserve(GetNodes(), -1);
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    Net->AddNode(NI.GetId(), NI.GetDat()); }
  TIntV EIdV;  GetEIdByTm(EIdV);
  TIntPrSet EdgeSet(GetEdges());
  for (int edge = 0; edge < EIdV.Len(); edge++) {
    const TEdgeI EI = GetEI(EIdV[edge]);
    const int Src = EI.GetSrcNId();
    const int Dst = EI.GetDstNId();
    if (Src==Dst || EdgeSet.IsKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)))) { continue; } // take only 1st edge
    EdgeSet.AddKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst)));
    Net->AddEdge(EI);
  }
  return Net;
}

Here is the call graph for this function:

void TTimeNENet::GetEdgeBuckets ( const int  EdgesPerBucket,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 844 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Gen(), GetEIdByTm(), and TVec< TVal, TSizeTy >::Len().

                                                                                             {
  TIntV EIdV;  GetEIdByTm(EIdV);
  TmBucketV.Gen(EIdV.Len()/EdgesPerBucket + 1, 0);
  for (int i = 0; i < EIdV.Len(); i++) {
    const int b = i/EdgesPerBucket;
    if (TmBucketV.Len() <= b) { TmBucketV.Add(TTimeNet::TTmBucket(TSecTm(b))); }
    TmBucketV[b].NIdV.Add(EIdV[i]);
  }
}

Here is the call graph for this function:

void TTimeNENet::GetEdgeTmBuckets ( const TTmUnit GroupBy,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 815 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), TTimeNet::TTmBucket::BegTm, TVec< TVal, TSizeTy >::Gen(), TSecTm::GetAbsSecs(), THash< TKey, TDat, THashFunc >::GetDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), GetEIdByTm(), THash< TKey, TDat, THashFunc >::GetKeyDatPrV(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TTimeNet::TTmBucket::NIdV, TSecTm::Round(), and TVec< TVal, TSizeTy >::Sort().

Referenced by PlotEffDiam(), and TimeGrowth().

                                                                                            {
  THash<TInt, TIntV> TmIdToEIdVH;
  TIntV EIdV;  GetEIdByTm(EIdV);
  for (int e = 0; e < EIdV.Len(); e++) {
    const int TmId = GetEDat(EIdV[e]).Round(TmUnit).GetAbsSecs();
    if (! TmIdToEIdVH.IsKey(TmId)) { TmIdToEIdVH.AddKey(TmId); }
    TmIdToEIdVH.GetDat(TmId).Add(EIdV[e]);
  }
  TVec<TPair<TInt, TIntV> > TmIdEIdVV;
  TmIdToEIdVH.GetKeyDatPrV(TmIdEIdVV);
  TmIdEIdVV.Sort();
  TmBucketV.Gen(TmIdEIdVV.Len());
  for (int i = 0; i < TmIdEIdVV.Len(); i++) {
    TTimeNet::TTmBucket& Bucket = TmBucketV[i];
    Bucket.BegTm = TmIdEIdVV[i].Val1;
    Bucket.NIdV = TmIdEIdVV[i].Val2;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TTimeNENet::GetEIdByTm ( TIntV EIdV) const

Definition at line 786 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TNodeEdgeNet< TSecTm, TSecTm >::BegEI(), TNodeEdgeNet< TSecTm, TSecTm >::EndEI(), TVec< TVal, TSizeTy >::Gen(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), TVec< TVal, TSizeTy >::Len(), and TVec< TVal, TSizeTy >::Sort().

Referenced by Get1stEdgeNet(), GetEdgeBuckets(), GetEdgeTmBuckets(), GetTriadEdges(), SaveEdgeTm(), and SetRndEdgeTimes().

                                             {
  TVec<TKeyDat<TSecTm, TInt> > TmToEIdV(GetEdges(), 0);
  for (TEdgeI EI= BegEI(); EI < EndEI(); EI++) {
    TmToEIdV.Add(TKeyDat<TSecTm, TInt>(EI.GetDat(), EI.GetId())); }
  TmToEIdV.Sort();
  EIdV.Gen(GetEdges(), 0);
  for (int i = 0; i < TmToEIdV.Len(); i++) {
    EIdV.Add(TmToEIdV[i].Dat); }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PTimeNENet TTimeNENet::GetESubGraph ( const TIntV EIdV) const

Definition at line 666 of file timenet.cpp.

References TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), TNodeEdgeNet< TSecTm, TSecTm >::GetNI(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TVec< TVal, TSizeTy >::Len(), New(), and TNodeEdgeNet< TNodeData, TEdgeData >::Reserve().

Referenced by TimeGrowth().

                                                           {
  PTimeNENet NewNetPt = TTimeNENet::New();
  TTimeNENet& NewNet = *NewNetPt;
  NewNet.Reserve(-1, EIdV.Len());
  for (int edge = 0; edge < EIdV.Len(); edge++) {
    const TEdgeI Edge = GetEI(EIdV[edge]);
    if (! NewNet.IsNode(Edge.GetSrcNId()))
      NewNet.AddNode(GetNI(Edge.GetSrcNId()));
    if (! NewNet.IsNode(Edge.GetDstNId()))
      NewNet.AddNode(GetNI(Edge.GetDstNId()));
    NewNet.AddEdge(Edge);
  }
  NewNet.Defrag();
  return NewNetPt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PTimeNENet TTimeNENet::GetGnmRndNet ( const int &  Nodes,
const int &  Edges 
) [static]

Definition at line 1224 of file timenet.cpp.

References TRnd::GetUniDevInt(), New(), and TInt::Rnd.

                                                                      {
  printf("Generating G_nm(%d, %d)\n", Nodes, Edges);
  int Src, Dst;
  PTimeNENet Net = TTimeNENet::New();
  Net->Reserve(Nodes, Edges);
  for (int e = 0; e < Edges; e++) {
    Src = TInt::Rnd.GetUniDevInt(Nodes);
    Dst = TInt::Rnd.GetUniDevInt(Nodes);
    while (Dst == Src || Net->IsEdge(Src, Dst)) {
      Dst = TInt::Rnd.GetUniDevInt(Nodes); }
    if (! Net->IsNode(Src)) { Net->AddNode(Src, TSecTm(e)); }
    if (! Net->IsNode(Dst)) { Net->AddNode(Dst, TSecTm(e)); }
    Net->AddEdge(Src, Dst, -1, TSecTm(e));
  }
  return Net;
}

Here is the call graph for this function:

PTimeNENet TTimeNENet::GetGraphUpToTm ( const TSecTm MaxEdgeTm) const

Definition at line 683 of file timenet.cpp.

References TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TNodeEdgeNet< TSecTm, TSecTm >::BegEI(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), TNodeEdgeNet< TSecTm, TSecTm >::EndEI(), TNodeEdgeNet< TSecTm, TSecTm >::GetNI(), IAssert, TSecTm::IsDef(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), and New().

                                                                   {
  PTimeNENet NewNetPt = TTimeNENet::New();
  TTimeNENet& NewNet = *NewNetPt;
  TSecTm PrevTm;
  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
    if (EI() > MaxEdgeTm) { break; }
    if (! NewNet.IsNode(EI.GetSrcNId()))
      NewNet.AddNode(GetNI(EI.GetSrcNId()));
    if (! NewNet.IsNode(EI.GetDstNId()))
      NewNet.AddNode(GetNI(EI.GetDstNId()));
    NewNet.AddEdge(EI);
    IAssert(! PrevTm.IsDef() || PrevTm <= EI()); // edge times must be sorted
    PrevTm = EI();
  }
  NewNet.Defrag();
  return NewNetPt;
}

Here is the call graph for this function:

void TTimeNENet::GetNIdByTm ( TIntV NIdV) const

Definition at line 776 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TVec< TVal, TSizeTy >::Gen(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), TVec< TVal, TSizeTy >::Len(), and TVec< TVal, TSizeTy >::Sort().

Referenced by GetNodeBuckets(), and GetTmBuckets().

                                             {
  TVec<TKeyDat<TSecTm, TInt> > TmToNIdV(GetNodes(), 0);
  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
    TmToNIdV.Add(TKeyDat<TSecTm, TInt>(NodeI.GetDat(), NodeI.GetId())); }
  TmToNIdV.Sort();
  NIdV.Gen(GetNodes(), 0);
  for (int i = 0; i < TmToNIdV.Len(); i++) {
    NIdV.Add(TmToNIdV[i].Dat); }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TTimeNENet::GetNodeBuckets ( const int  NodesPerBucket,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 834 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Gen(), GetNIdByTm(), and TVec< TVal, TSizeTy >::Len().

                                                                                             {
  TIntV NIdV;  GetNIdByTm(NIdV);
  TmBucketV.Gen(NIdV.Len() / NodesPerBucket + 1, 0);
  for (int i = 0; i < NIdV.Len(); i++) {
    const int b = i/NodesPerBucket;
    if (TmBucketV.Len() <= b) { TmBucketV.Add(TTimeNet::TTmBucket(TSecTm(b))); }
    TmBucketV[b].NIdV.Add(NIdV[i]);
  }
}

Here is the call graph for this function:

PTimeNENet TTimeNENet::GetPrefAttach ( const int &  Nodes,
const int &  Edges,
const double &  GammaIn,
const double &  GammaOut 
) [static]

Definition at line 1242 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TRnd::GetUniDevInt(), IAssert, TVec< TVal, TSizeTy >::Len(), New(), and TInt::Rnd.

                                                                                                                      {
  const double Alpha = Nodes/double(Edges);
  printf("Generating PA(%d, %d), with slope in:%.1f, out: %.1f\n", Nodes, Edges,
    2+GammaIn/(Alpha/(1-Alpha)), 2+GammaOut/(Alpha/(1-Alpha)));
  // init
  int nodes=0, edges=0, time=0, iter=0;
  TIntV OutW(Edges, 0), InW(Edges, 0);
  PTimeNENet Net = TTimeNENet::New();
  Net->Reserve(Nodes, Edges);
  // 1st node
  Net->AddNode(0, TSecTm(time++));  nodes++;
  OutW.Add(0);  InW.Add(0);
  while (edges < Edges) {
    int Src=-1, Dst=-1;  iter++;
    if (TInt::Rnd.GetUniDev() < Alpha) {
      if (nodes < Nodes) {
        IAssert(Net->AddNode(nodes, TSecTm(time++)));
        nodes++; }
    } else {
      if (TInt::Rnd.GetUniDev() < nodes*GammaIn/double(edges+nodes*GammaIn)) {
        Src = TInt::Rnd.GetUniDevInt(nodes); }
      else { Src = OutW[TInt::Rnd.GetUniDevInt(OutW.Len())]; }
      if (TInt::Rnd.GetUniDev() < nodes*GammaOut/double(edges+nodes*GammaOut)) {
        Dst = TInt::Rnd.GetUniDevInt(nodes); }
      else { Dst = InW[TInt::Rnd.GetUniDevInt(InW.Len())]; }
    }
    if (Src == Dst || Net->IsEdge(Src, Dst)) {
      continue;
    }
    //printf("%d/%d %d %d\n", edges, iter, Src, Dst);
    if (! Net->IsNode(Src)) { Net->AddNode(Src, TSecTm(time++)); nodes++; }
    if (! Net->IsNode(Dst)) { Net->AddNode(Dst, TSecTm(time++)); nodes++; }
    Net->AddEdge(Src, Dst, -1, TSecTm(time++));
    OutW.Add(Src); InW.Add(Dst); edges++;
  }
  for (int node = 0; node < Nodes; node++) {
    if (! Net->IsNode(node)) {
      Net->AddNode(node, TSecTm(time++)); }
  }
  return Net;
}

Here is the call graph for this function:

PTimeNENet TTimeNENet::GetPrefAttach ( const int &  Nodes,
const int &  OutDeg 
) [static]

Definition at line 1284 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), THashSet< TKey, THashFunc >::AddKey(), THashSet< TKey, THashFunc >::Clr(), TVec< TVal, TSizeTy >::Len(), THashSet< TKey, THashFunc >::Len(), New(), and TInt::Rnd.

                                                                        {
  printf("Generating PA, nodes:%d, out-deg:%d\n", Nodes, OutDeg);
  // init
  int time=0;
  PTimeNENet Net = TTimeNENet::New();
  Net->Reserve(Nodes, OutDeg*Nodes);
  Net->AddNode(0, TSecTm(++time));  Net->AddNode(1, TSecTm(++time));
  Net->AddEdge(0, 1, -1, TSecTm(++time));
  TIntV NIdV;  NIdV.Add(0);  NIdV.Add(1);
  TIntSet NodeSet;
  for (int node = 2; node <= Nodes; node++) {
    NodeSet.Clr(false);
    while (NodeSet.Len() < OutDeg && NodeSet.Len() < node) {
      NodeSet.AddKey(NIdV[TInt::Rnd.GetUniDevInt(NIdV.Len())]);
    }
    const int N = Net->AddNode(node, TSecTm(++time));
    for (int i = 0; i < NodeSet.Len(); i++) {
      Net->AddEdge(node, NodeSet[i], -1, TSecTm(++time));
      NIdV.Add(N);  NIdV.Add(NodeSet[i]);
    }
  }
  return Net;
}

Here is the call graph for this function:

Definition at line 1329 of file timenet.cpp.

References New().

                                   {
  PTimeNENet Net = TTimeNENet::New();
  for (int i = 1; i <= 6; i++) {
    Net->AddNode(i, TSecTm(0)); }
  int tm = 1;
  Net->AddEdge(1, 2, -1, TSecTm(tm++));
  Net->AddEdge(3, 4, -1, TSecTm(tm++));
  Net->AddEdge(3, 1, -1, TSecTm(tm++));
  Net->AddEdge(5, 6, -1, TSecTm(tm++));
  Net->AddEdge(6, 4, -1, TSecTm(tm++));
  Net->AddEdge(5, 3, -1, TSecTm(tm++));
  Net->AddEdge(5, 4, -1, TSecTm(tm++));
  Net->AddEdge(5, 2, -1, TSecTm(tm++));
  return Net;
}

Here is the call graph for this function:

PTimeNENet TTimeNENet::GetSubGraph ( const TIntV NIdV) const

Definition at line 645 of file timenet.cpp.

References TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), TNodeEdgeNet< TSecTm, TSecTm >::GetNDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNI(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TVec< TVal, TSizeTy >::Len(), New(), and TNodeEdgeNet< TNodeData, TEdgeData >::Reserve().

                                                          {
  PTimeNENet NewNetPt = TTimeNENet::New();
  TTimeNENet& NewNet = *NewNetPt;
  NewNet.Reserve(NIdV.Len(), -1);
  int node, edge;
  TNodeI NI;
  for (node = 0; node < NIdV.Len(); node++) {
    NewNet.AddNode(NIdV[node], GetNDat(NIdV[node]));
  }
  for (node = 0; node < NIdV.Len(); node++) {
    NI = GetNI(NIdV[node]);
    for (edge = 0; edge < NI.GetOutDeg(); edge++) {
      const TEdgeI EI = GetEI(NI.GetOutEId(edge));
      if (NewNet.IsNode(EI.GetDstNId())) {
        NewNet.AddEdge(EI); }
    }
  }
  NewNet.Defrag();
  return NewNetPt;
}

Here is the call graph for this function:

Definition at line 610 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::BegEI(), TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::EndEI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), and New().

                                      {
  PTimeNet NewNet = TTimeNet::New();
  NewNet->Reserve(GetNodes(), -1);
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    NewNet->AddNode(NI.GetId(), NI.GetDat());
  }
  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
    const int src = EI.GetSrcNId();
    const int dst = EI.GetDstNId();
    if (! NewNet->IsEdge(src, dst)) {
      NewNet->AddEdge(src, dst); }
  }
  NewNet->Defrag();
  return NewNet;
}

Here is the call graph for this function:

void TTimeNENet::GetTmBuckets ( const TTmUnit GroupBy,
TTimeNet::TTmBucketV TmBucketV 
) const

Definition at line 796 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), TTimeNet::TTmBucket::BegTm, TVec< TVal, TSizeTy >::Gen(), TSecTm::GetAbsSecs(), THash< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::GetKeyDatPrV(), TNodeEdgeNet< TSecTm, TSecTm >::GetNDat(), GetNIdByTm(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TTimeNet::TTmBucket::NIdV, TSecTm::Round(), and TVec< TVal, TSizeTy >::Sort().

                                                                                        {
  THash<TInt, TIntV> TmIdToNIdVH;
  TIntV NIdV;  GetNIdByTm(NIdV);
  for (int n = 0; n < NIdV.Len(); n++) {
    const int TmId = GetNDat(NIdV[n]).Round(TmUnit).GetAbsSecs();
    if (! TmIdToNIdVH.IsKey(TmId)) { TmIdToNIdVH.AddKey(TmId); }
    TmIdToNIdVH.GetDat(TmId).Add(NIdV[n]);
  }
  TVec<TPair<TInt, TIntV> > TmIdNIdVV;
  TmIdToNIdVH.GetKeyDatPrV(TmIdNIdVV);
  TmIdNIdVV.Sort();
  TmBucketV.Gen(TmIdNIdVV.Len());
  for (int i = 0; i < TmIdNIdVV.Len(); i++) {
    TTimeNet::TTmBucket& Bucket = TmBucketV[i];
    Bucket.BegTm = TmIdNIdVV[i].Val1;
    Bucket.NIdV = TmIdNIdVV[i].Val2;
  }
}

Here is the call graph for this function:

int TTimeNENet::GetTriadEdges ( TIntV TriadEIdV) const

Definition at line 855 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TUNGraph::AddEdge(), TUNGraph::AddNode(), TVec< TVal, TSizeTy >::Clr(), TSnap::GetCmnNbrs(), TUNGraph::GetEdges(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), GetEIdByTm(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), TExeTm::GetStr(), TUNGraph::IsEdge(), TUNGraph::IsNode(), TVec< TVal, TSizeTy >::Len(), and New().

                                                    {
  PUNGraph Graph = TUNGraph::New(GetNodes(), GetEdges());
  TIntV EIdV;  GetEIdByTm(EIdV);
  TriadEIdV.Clr();
  TExeTm ExeTm;
  for (int edge = 0; edge < EIdV.Len(); edge++) {
    const TEdgeI EI = GetEI(EIdV[edge]);
    const int Src = EI.GetSrcNId();
    const int Dst = EI.GetDstNId();
    if (Src==Dst || Graph->IsEdge(Src, Dst)) { continue; } // take only 1st edge
    if (! Graph->IsNode(Src)) { Graph->AddNode(Src); }
    if (! Graph->IsNode(Dst)) { Graph->AddNode(Dst); }
    if (TSnap::GetCmnNbrs(Graph, Src, Dst) > 0) { TriadEIdV.Add(EIdV[edge]); }
    Graph->AddEdge(Src, Dst);
    if (edge % 10000 == 0) {
      printf("\redges %dk / %dk: triangle edges: %dk [total %s]", edge/1000, EIdV.Len()/1000,
        TriadEIdV.Len()/1000, ExeTm.GetStr()); }
  }
  return Graph->GetEdges();
}

Here is the call graph for this function:

static PTimeNENet TTimeNENet::Load ( TSIn SIn) [inline, static]

Static constructor that loads the network from a stream SIn and returns a pointer to it.

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 88 of file timenet.h.

References TTimeNENet().

{ return new TTimeNENet(SIn); }

Here is the call graph for this function:

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.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), TSecTm::GetCurTm(), TSsParser::GetFld(), TSecTm::GetStr(), TExeTm::GetStr(), IAssert, TSsParser::IsCmt(), TSsParser::Len(), Mega, TMath::Mn(), TMath::Mx(), New(), and TSsParser::Next().

                                                                                                                                        {
  printf("Loading %s\n", EdgeFNm.CStr());
  PTimeNENet Net = TTimeNENet::New();
  TStrHash<TInt> StrToId(Mega(1), true); // node id to string
  int LineCnt=0;
  TExeTm ExeTm;
  TSsParser Ss(EdgeFNm, Separator);
  TSecTm MinTm=TSecTm::GetCurTm(), MaxTm=TSecTm(100);
  while (Ss.Next()) {
    if (Ss.IsCmt()) { continue; }
    IAssert(Ss.Len() > TimeFld);
    const char* Node1 = Ss.GetFld(SrcFld);
    const char* Node2 = Ss.GetFld(DstFld);
    const char* TmStr = Ss.GetFld(TimeFld);
    if (strcmp(TmStr,"NULL")==0) { continue; }
    //const TSecTm Tm = TSecTm::GetDtTmFromYmdHmsStr(TmStr);
    const TSecTm Tm(atoi(TmStr));
    const int NId1 = StrToId.AddKey(Node1);
    const int NId2 = StrToId.AddKey(Node2);
    if (! Net->IsNode(NId1)) { Net->AddNode(NId1, TSecTm()); }
    if (! Net->IsNode(NId2)) { Net->AddNode(NId2, TSecTm()); }
    MinTm=TMath::Mn(MinTm, Tm);
    MaxTm=TMath::Mx(MaxTm, Tm);
    Net->AddEdge(NId1, NId2, -1, Tm);
    if (++LineCnt % 1000 == 0) {
      printf("\r  %dk lines processed: %d %d [%s]", LineCnt/1000, Net->GetNodes(), Net->GetEdges(), ExeTm.GetStr()); }
  }
  printf("\r  %d lines processed: %d %d [%s]\n", LineCnt, Net->GetNodes(), Net->GetEdges(), ExeTm.GetStr());
  printf("  Data range %s -- %s\n", MinTm.GetStr().CStr(), MaxTm.GetStr().CStr());
  //TSnap::PrintInfo(Net, "", "", false);
  Net->UpdateNodeTimes();
  return Net;
}

Here is the call graph for this function:

PTimeNENet TTimeNENet::LoadFlickr ( const TStr NodeFNm,
const TStr EdgeFNm 
) [static]

Definition at line 1345 of file timenet.cpp.

References TStr::CStr(), TSsParser::GetInt(), TSsParser::GetLineNo(), TSecTm::GetStr(), New(), TSsParser::Next(), and ssfWhiteSep.

                                                                          {
  const int BegOfTm = 1047369600; // Tue Mar 11 01:00:00 2003 (begining of Flickr)
  PTimeNENet Net = TTimeNENet::New();
  printf("Adding nodes...");
  { TSsParser Ss(NodeFNm, ssfWhiteSep);
  while (Ss.Next()) {
    const int NId = Ss.GetInt(0);
    const int Tm = Ss.GetInt(1)+BegOfTm;
    if (TSecTm(Tm) < TSecTm(2002, 1, 1)) {
      printf("  skip node %g (time %d)\n", (double) Ss.GetLineNo(), Ss.GetInt(1)); continue; }
    Net->AddNode(NId, TSecTm(Tm));
  } }
  printf(" %d nodes\n", Net->GetNodes());
  printf("Adding edges...");
  int SkipCnt=0;
  //TIntH SkipDiffCnt;
  { TSsParser Ss(EdgeFNm, ssfWhiteSep);
  while (Ss.Next()) {
    const int NId1 = Ss.GetInt(0);
    const int NId2 = Ss.GetInt(1);
    const TSecTm Tm = TSecTm(Ss.GetInt(2)+BegOfTm);
    if (! Net->IsNode(NId1) || ! Net->IsNode(NId2)) { printf("not node\n"); continue; }
    if (Tm < TSecTm(2002, 1, 1)) { SkipCnt++;
      printf("  skip edge %g (time %s)\n", (double) Ss.GetLineNo(), Tm.GetStr().CStr()); continue; }
    if (Tm+600 < Net->GetNDat(NId1)) {
      printf("  1:skip edge %g (time %s < %s)\n", (double) Ss.GetLineNo(), Tm.GetStr().CStr(), Net->GetNDat(NId1).GetStr().CStr());
      //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId1).GetAbsSecs()) += 1;
      SkipCnt++;  continue; }
    if (Tm+600 < Net->GetNDat(NId2)) { SkipCnt++;
      printf("  2:skip edge %g (time %s < %s)\n", (double) Ss.GetLineNo(), Tm.GetStr().CStr(), Net->GetNDat(NId2).GetStr().CStr());
      //SkipDiffCnt.AddDat(-Tm.GetAbsSecs()+Net->GetNDat(NId2).GetAbsSecs()) += 1;
      SkipCnt++;  continue; }
    Net->AddEdge(NId1, NId2, -1, TSecTm(Tm));
  } }
  //TGnuPlot::PlotValCntH(SkipDiffCnt, "flickr-edgeNodeDiff", "", "seconds", "count");
  printf("  %d edges\n", Net->GetEdges());
  printf("  %d edges skipped (edge time < node time)\n", SkipCnt);
  Net->UpdateNodeTimes();
  return Net;
}

Here is the call graph for this function:

static PTimeNENet TTimeNENet::New ( ) [inline, static]

Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New().

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 86 of file timenet.h.

References TTimeNENet().

Referenced by Get1stEdgeNet(), GetESubGraph(), GetGnmRndNet(), GetGraphUpToTm(), GetPrefAttach(), GetSmallNet(), GetSubGraph(), GetTimeNet(), GetTriadEdges(), LoadEdgeTm(), LoadFlickr(), and TimeGrowth().

{ return new TTimeNENet(); }

Here is the call graph for this function:

Here is the caller graph for this function:

static PTimeNENet TTimeNENet::New ( const int &  Nodes,
const int &  Edges 
) [inline, static]

Definition at line 87 of file timenet.h.

References TTimeNENet().

{ return new TTimeNENet(Nodes, Edges); }

Here is the call graph for this function:

TTimeNENet & TTimeNENet::operator= ( const TTimeNENet TimeNet)

Definition at line 603 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::operator=().

                                                             {
  if (this != &TimeNet) {
    TNet::operator=(TimeNet);
  }
  return *this;
}

Here is the call graph for this function:

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.

References TVec< TVal, TSizeTy >::Add(), TGnuPlot::AddErrBar(), TVec< TVal, TSizeTy >::AddV(), TStr::CStr(), TStr::Fmt(), TSnap::GetAnfEffDiam(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), GetEdgeTmBuckets(), TSnap::GetMxWcc(), TNGraph::GetNodes(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), TStr::GetNullStr(), TExeTm::GetTmStr(), TTmInfo::GetTmUnitStr(), TVec< TVal, TSizeTy >::Len(), TGnuPlot::SavePng(), TGnuPlot::SetXYLabel(), TVec< TVal, TSizeTy >::Sort(), and TExeTm::Tick().

                                                                                                     {
  TTimeNet::TTmBucketV TmBucketV;
  GetEdgeTmBuckets(TmUnit, TmBucketV);
  PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
  TIntV EdgeIdV;
  TExeTm ExeTm, Run1Tm;
  TFltTrV TmDiamV, NdsDiamV;
  for (int t = 0; t < TmBucketV.Len(); t++) {
    EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
    printf("\n*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr(TmUnit).CStr(), EdgeIdV.Len());  ExeTm.Tick();
    if (TmBucketV[t].BegTm < StartTm) continue;
    PNGraph PreGraph = TSnap::ConvertESubGraph<PNGraph>(FullGraph, EdgeIdV);
    TMom Mom;
    double EffDiam = 0.0;
    for (int r = 0; r < NDiamRuns; r++) {
      printf("%d...", r+1);  Run1Tm.Tick();
      if (OnlyWcc) { EffDiam = TSnap::GetAnfEffDiam(TSnap::GetMxWcc(PreGraph)); }
      else { EffDiam = TSnap::GetAnfEffDiam(PreGraph); }
      Mom.Add(EffDiam);
      printf("[%s]\r", Run1Tm.GetTmStr());
    }
    Mom.Def();
    TmDiamV.Add(TFltTr(TmBucketV[t].BegTm.Round(TmUnit).GetAbsSecs(), Mom.GetMean(), Mom.GetSDev()));
    NdsDiamV.Add(TFltTr(PreGraph->GetNodes(), Mom.GetMean(), Mom.GetSDev()));
    NdsDiamV.Sort();
    printf("  [%s]          \n", ExeTm.GetTmStr());
    const TStr WccStr = OnlyWcc ? "WCC " : TStr::GetNullStr();
    { TGnuPlot GnuPlot("diamEff1."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
    GnuPlot.SetXYLabel(TStr::Fmt("TIME [%s]", TTmInfo::GetTmUnitStr(TmUnit).CStr()), "AVERAGE "+WccStr+"Effective Diameter");
    GnuPlot.AddErrBar(TmDiamV, "", "");
    GnuPlot.SavePng(); }
    { TGnuPlot GnuPlot("diamEff2."+FNmPref, TStr::Fmt("%s. G(%d, %d). %d RUNS.", Desc.CStr(), GetNodes(), GetEdges(), NDiamRuns));
    GnuPlot.SetXYLabel("NODES", "AVERAGE "+WccStr+"Effective Diameter");
    GnuPlot.AddErrBar(NdsDiamV, "", "");
    GnuPlot.SavePng(); }
  }
}

Here is the call graph for this function:

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.

References TStr::CStr(), TSecTm::GetStr(), and TTmInfo::GetTmUnitStr().

                                                                                                               {
  printf("\nGrowth over time: degree distribution, Growth Power Law, Diameter.\n  %s group by %s.\n",
    FNmPref.CStr(), TTmInfo::GetTmUnitStr(TmUnit).CStr());
  printf("  Delete out-edges of pre time %s nodes.\n  Take subgraph of post year %s subgraph.\n\n",
    DelPreTmEdges.GetStr().CStr(), PostTmDiam.GetStr().CStr());
  // run diameter
  /*const int NSamples = 100;
  const int NDiamRuns = 10;
  // delete past
  if (DelPreEdges != -1) {
    TIntV EdgeIdV;
    printf("Deleting pre-year %d edges\n", DelPreEdges);
    for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
      if (EI().GetYear() < DelPreEdges) { EdgeIdV.Add(EI.GetId()); } }
    for (int e = 0; e < EdgeIdV.Len(); e++) { DelEdge(EdgeIdV[e]); }
    printf("  Deleted %d edges (out of %d edges total).\n", EdgeIdV.Len(), GetEdges());
  }
  PNEGraph FullGraph = GetNEGraph();
  TSnap::DelZeroDegNodes(FullGraph);

  PGrowthStat GrowthStat = TGrowthStat::New(TmUnit, TGraphStat::AllStat());
  TFltV PreDiamSDev, PreEffDiamSDev, WccDiamSDev, WccEffDiamSDev;
  TIntV EdgeIdV;
  TExeTm ExeTm;
  TTimeNet::TTmBucketV EdgeTmBucketV;
  GetEdgeTmBuckets(TmUnit, EdgeTmBucketV);
  for (int t = 0; t < EdgeTmBucketV.Len(); t++) {
    printf("\nGraph: %s (%d / %d) [%s]\n", EdgeTmBucketV[t].BegTm.GetTmStr().CStr(),
      t+1, EdgeTmBucketV.Len(), TExeTm::GetCurTm());
    // up-to-year subgraph
    EdgeIdV.AddV(EdgeTmBucketV[t].NIdV); // nodes up to time T
    if (EdgeTmBucketV[t].BegTm.GetYear() < PostYearDiam) continue;

    const PNEGraph PreNEGraph = EdgeBothWays ? FullGraph->GetEdgeSubGraph(EdgeIdV) : FullGraph;
    PNGraph PreGraph = PreNEGraph->GetBWayGraph();
    PNGraph WccGraph = TSnap::GetMxWcc(PreGraph);

    // find nodes that are not in missing past
    TIntV PostYearNIdV, WccPostYearNIdV;
    THash<TIntPr, TInt> PostYearEdgeH;
    for (TNEGraph::TEdgeI EI = PreNEGraph->BegEI(); EI < PreNEGraph->EndEI(); EI++) {
      if (GetEDat(EI.GetId()).GetYear() >= PostYearDiam) {
        PostYearEdgeH.AddKey(TIntPr(EI.GetSrcNId(), EI.GetDstNId())); }
    }
    TIntH PostYearNIdH;
    for (int i = 0; i < PostYearEdgeH.Len(); i++) {
      if ((! EdgeBothWays) || (EdgeBothWays && PostYearEdgeH.IsKey(TIntPr(PostYearEdgeH.GetKey(i).Val2, PostYearEdgeH.GetKey(i).Val1)))) { //reverse edge exists
        PostYearNIdH.AddKey(PostYearEdgeH.GetKey(i).Val1);
        PostYearNIdH.AddKey(PostYearEdgeH.GetKey(i).Val2);
      }
    }
    PostYearNIdH.GetKeyV(PostYearNIdV);
    for (int i = 0; i < PostYearNIdV.Len(); i++) {
      if (WccGraph->IsNode(PostYearNIdV[i])) {
        WccPostYearNIdV.Add(PostYearNIdV[i]); }
    }

    // diameter of PostYearDiam subgraph using whole graph (all edges)
    TMom PreDiamMom, PreEffDiamMom, WccDiamMom, WccEffDiamMom;
    for (int r = 0; r < NDiamRuns; r++) {
      if (! PostYearNIdV.Empty()) {
        PreDiamMom.Add(-1); //PreDiamMom.Add(TSnap::GetBfsFullDiam(PreGraph, NSamples, PostYearNIdV, false));
        PreEffDiamMom.Add(TSnap::GetBfsEffDiam(PreGraph, NSamples, PostYearNIdV, false));
      }
      if (! WccPostYearNIdV.Empty()) {
        //WccDiamMom.Add(TSnap::GetBfsFullDiam(WccGraph, NSamples, WccPostYearNIdV, false));
        //WccEffDiamMom.Add(TSnap::GetBfsEffDiam(WccGraph, NSamples, WccPostYearNIdV, false));
        WccDiamMom.Add(-1);  WccEffDiamMom.Add(-1);
      }
      printf("  diam: %d  [%s]  %.2f\r", r+1, ExeTm.GetTmStr(), PreEffDiamMom.GetValV().Last().Val);  ExeTm.Tick();
    }
    PreDiamMom.Def();  PreEffDiamMom.Def();
    WccDiamMom.Def();  WccEffDiamMom.Def();
    // save stat
    PGraphStat GraphStatPt = GrowthStat->Add(EdgeTmBucketV[t].BegTm);
    TGraphStat& GraphStat = *GraphStatPt;
    GraphStat.Nodes = PreGraph->GetNodes();
    GraphStat.NonZNodes = PreGraph->GetNodes() - TSnap::CntDegNodes<PNGraph>(PreGraph, 0);
    GraphStat.Srcs =  GraphStat.Nodes - TSnap::CntOutDegNodes<PNGraph>(PreGraph, 0);
    GraphStat.Edges = PreGraph->GetEdges();
    GraphStat.WccNodes= WccGraph->GetNodes();
    GraphStat.WccEdges = WccGraph->GetEdges();
    GraphStat.FullDiam = PreDiamMom.GetMean(); // mean
    GraphStat.EffDiam = PreEffDiamMom.GetMean();
    GraphStat.FullWccDiam = WccDiamMom.GetMean();
    GraphStat.EffWccDiam = WccEffDiamMom.GetMean();
    GraphStat.FullDiamDev = PreDiamMom.GetSDev(); // variance
    GraphStat.EffDiamDev = PreEffDiamMom.GetSDev();
    GraphStat.FullWccDiamDev = WccDiamMom.GetSDev();
    GraphStat.EffWccDiamDev = WccEffDiamMom.GetSDev();
    { TFOut FOut("growth."+FNmPref+".bin");
    GrowthStat->Save(FOut); }
    const TStr BigDesc = TStr::Fmt("%s. MISSING PAST DIAMETER\nDelPreEdges\t%d\nPostYearDiam\t%d\n",
      Desc.CStr(), DelPreEdges, PostYearDiam);
    GrowthStat->SaveTxt(FNmPref, BigDesc);
  }
  // diameter plots
  GrowthStat->PlotDiam(FNmPref, Desc + TStr::Fmt(" MISSING PAST. DelPre:%d PostYear:%d.",
    DelPreEdges, PostYearDiam));
    */
}

Here is the call graph for this function:

void TTimeNENet::Save ( TSOut SOut) const [inline, virtual]

Saves the network to a (binary) stream SOut.

Reimplemented from TNodeEdgeNet< TSecTm, TSecTm >.

Definition at line 85 of file timenet.h.

References TNodeEdgeNet< TSecTm, TSecTm >::Save().

{ TNet::Save(SOut); }

Here is the call graph for this function:

void TTimeNENet::SaveEdgeTm ( const TStr EdgeFNm,
const bool &  RenumberNId = false,
const bool &  RelativeTm = false 
) const

Definition at line 1308 of file timenet.cpp.

References THashSet< TKey, THashFunc >::AddKey(), TStr::CStr(), THashSet< TKey, THashFunc >::Gen(), TSecTm::GetAbsSecs(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), GetEIdByTm(), THashSet< TKey, THashFunc >::GetKeyId(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), and TVec< TVal, TSizeTy >::Len().

                                                                                                      {
  TIntV EIdV;  GetEIdByTm(EIdV);
  const int BegTm = RelativeTm ? GetEDat(EIdV[0]).GetAbsSecs() : 0;
  TIntSet NIdMap;
  if (RenumberNId) { NIdMap.Gen(GetNodes()); }
  FILE *F = fopen(EdgeFNm.CStr(), "wt");
  //fprintf(F, "#Nodes\t%d\n#Edges\t%d\n", GetNodes(), GetEdges());
  //fprintf(F, "#<src>\t<dst>\t<time>\n");
  for (int e =0; e < EIdV.Len(); e++) {
    const TEdgeI EI = GetEI(EIdV[e]);
    if (RenumberNId) {
      const int src = EI.GetSrcNId();
      const int dst = EI.GetDstNId();
      NIdMap.AddKey(src);  NIdMap.AddKey(dst);
      fprintf(F, "%d\t%d\t%d\n", NIdMap.GetKeyId(src), NIdMap.GetKeyId(dst), EI().GetAbsSecs()-BegTm);
    }else {
      fprintf(F, "%d\t%d\t%d\n", EI.GetSrcNId(), EI.GetDstNId(), EI().GetAbsSecs()-BegTm); }
  }
  fclose(F);
}

Here is the call graph for this function:

Definition at line 723 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), IAssert, and TSecTm::IsDef().

                                        {
  int Cnt = 0;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    if (NI.GetDeg() == 0) { continue; }
    TSecTm NodeTm;
    for (int edge = 0; edge < NI.GetOutDeg(); edge++) {
      const TSecTm& EdgeTm = GetEDat(NI.GetOutEId(edge));  IAssert(EdgeTm.IsDef());
      if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
    }
    for (int edge = 0; edge < NI.GetInDeg(); edge++) {
      const TSecTm& EdgeTm = GetEDat(NI.GetInEId(edge));  IAssert(EdgeTm.IsDef());
      if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
    }
    GetNDat(NI.GetId()) = NodeTm;
  }
  printf("Node times set: %d/%d updates\n", Cnt, GetNodes());
}

Here is the call graph for this function:

void TTimeNENet::SetRndEdgeTimes ( const int &  MinTmEdge = 0)

Definition at line 742 of file timenet.cpp.

References TVec< TVal, TSizeTy >::Add(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), GetEIdByTm(), TVec< TVal, TSizeTy >::Len(), TInt::Rnd, TVec< TVal, TSizeTy >::Swap(), and UpdateNodeTimes().

                                                     {
  printf("Shuffling last %d (%d%%) edge arrival times..\n", GetEdges()-MinTmEdge, int(100.0*(GetEdges()-MinTmEdge)/double(GetEdges())));
  TIntV RndEIdV;  GetEIdByTm(RndEIdV);
  TIntV TrueEIdV = RndEIdV;
  TSecTmV TrueTmV;
  const int SwapLen = RndEIdV.Len()-MinTmEdge;
  for (int R = 0; R < 10; R++) {
    for (int i = MinTmEdge; i < RndEIdV.Len(); i++) {
      RndEIdV.Swap(TInt::Rnd.GetUniDevInt(SwapLen)+MinTmEdge, TInt::Rnd.GetUniDevInt(SwapLen)+MinTmEdge); }
  }
  for (int e = 0; e < TrueEIdV.Len(); e++) {
    TrueTmV.Add(GetEDat(TrueEIdV[e])); }
  for (int e = 0; e < RndEIdV.Len(); e++) {
    GetEDat(RndEIdV[e]) = TrueTmV[e]; }
  UpdateNodeTimes();
}

Here is the call graph for this function:

Definition at line 701 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::EdgeH, TNodeEdgeNet< TSecTm, TSecTm >::NodeH, and THash< TKey, TDat, THashFunc >::SortByDat().

                                   {
  NodeH.SortByDat(true);
  EdgeH.SortByDat(true);
}

Here is the call graph for this function:

PGStatVec TTimeNENet::TimeGrowth ( const TTmUnit TimeStep,
const TFSet TakeStat,
const TSecTm StartTm = TSecTm(1) 
) const

Definition at line 876 of file timenet.cpp.

References TVec< TVal, TSizeTy >::AddV(), GetEdgeTmBuckets(), GetESubGraph(), TExeTm::GetTmStr(), TVec< TVal, TSizeTy >::Len(), New(), and TExeTm::Tick().

                                                                                                            {
  TExeTm ExeTm;
  PGStatVec GStatVec = TGStatVec::New(TimeStep, TakeStat);
  TTimeNet::TTmBucketV TmBucketV;
  GetEdgeTmBuckets(TimeStep, TmBucketV);
  const PNEGraph FullGraph = TSnap::ConvertGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this));
  TIntV EdgeIdV;
  for (int t = 0; t < TmBucketV.Len(); t++) {
    EdgeIdV.AddV(TmBucketV[t].NIdV); // edges up to time T
    printf("\n***%d/%d: %s (%d edges) ", t+1, TmBucketV.Len(), TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.Len());  ExeTm.Tick();
    if (TmBucketV[t].BegTm < StartTm) { continue; }
    const PNEGraph PreGraph = TSnap::GetESubGraph(FullGraph, EdgeIdV);
    GStatVec->Add(PreGraph, TmBucketV[t].BegTm);
    printf("  [%s]\n", ExeTm.GetTmStr());
    //{ TFOut FOut("LinkedIn.GStatVec");  GStatVec->Save(FOut); }
  }
  return GStatVec;
}

Here is the call graph for this function:

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.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::AddV(), TVec< TVal, TSizeTy >::Clr(), TStr::CStr(), TStr::Fmt(), GetEdgeTmBuckets(), GetESubGraph(), TExeTm::GetTmStr(), TVec< TVal, TSizeTy >::Len(), TGStat::NDiamRuns, New(), TPt< TRec >::Save(), and TExeTm::Tick().

                                                                                                         {
  TGStat::NDiamRuns = NDiamRuns;
  PGStatVec GrowthStat = TGStatVec::New(TmUnit, TakeStat);
  TTimeNet::TTmBucketV TmBucketV;
  GetEdgeTmBuckets(TmUnit, TmBucketV);
  TIntV EdgeIdV;
  TExeTm ExeTm;
  for (int t = 0; t < TmBucketV.Len(); t++) {
    // take graph over last TakeNTmUnits time units
    if (TakeNTmUnits == -1) {
      EdgeIdV.AddV(TmBucketV[t].NIdV); }
    else {
      if (t < TakeNTmUnits) { continue; }
      EdgeIdV.Clr(false);
      for (int i = t-TakeNTmUnits; i < t; i++) { EdgeIdV.AddV(TmBucketV[i].NIdV); }
    }
    printf("*** %s (%d edges)\n", TmBucketV[t].BegTm.GetStr().CStr(), EdgeIdV.Len());  ExeTm.Tick();
    PNEGraph PreGraph = TSnap::ConvertESubGraph<PNEGraph>(PTimeNENet((TTimeNENet*)this), EdgeIdV);
    if (LinkBWays) {
      TIntV KeepEIdV; // keep only nodes that have in- and out-links (send and receive email)
      for (TNEGraph::TEdgeI EI = PreGraph->BegEI(); EI < PreGraph->EndEI(); EI++) {
        if (PreGraph->IsEdge(EI.GetDstNId(), EI.GetSrcNId(), true)) { KeepEIdV.Add(EI.GetId()); }
      }
      PreGraph = TSnap::GetESubGraph(PreGraph, KeepEIdV);
    }
    // take statistics
    GrowthStat->Add(PreGraph, TmBucketV[t].BegTm);
    { TFOut FOut(TStr::Fmt("growth.%s.gStatVec", FNmPref.CStr()));
    GrowthStat->Save(FOut); }
    GrowthStat->SaveTxt(FNmPref, Desc);
    printf("  [%s]\n", ExeTm.GetTmStr());
  }
  return GrowthStat;
}

Here is the call graph for this function:

Definition at line 707 of file timenet.cpp.

References TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), and TSecTm::IsDef().

Referenced by SetRndEdgeTimes().

                                 {
  int Cnt = 0;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    TSecTm& NodeTm = NI();
    for (int edge = 0; edge < NI.GetOutDeg(); edge++) {
      const TSecTm& EdgeTm = GetEDat(NI.GetOutEId(edge));
      if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
    }
    for (int edge = 0; edge < NI.GetInDeg(); edge++) {
      const TSecTm& EdgeTm = GetEDat(NI.GetInEId(edge));
      if (! NodeTm.IsDef() || EdgeTm < NodeTm) { NodeTm = EdgeTm; Cnt++; }
    }
  }
  printf("Update node times: %d/%d updates\n", Cnt, GetNodes());
}

Here is the call graph for this function:

Here is the caller graph for this function:


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: