SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TCascade Class Reference

#include <cascdynetinf.h>

Public Member Functions

 TCascade ()
 
 TCascade (const int &model)
 
 TCascade (const int &cid, const int &model)
 
 TCascade (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
void Clr ()
 
int GetId ()
 
int Len () const
 
int LenBeforeT (const double &T)
 
int LenAfterT (const double &T)
 
int GetNode (const int &i) const
 
THash< TInt, THitInfo >::TIter BegI () const
 
THash< TInt, THitInfo >::TIter EndI () const
 
int GetModel () const
 
double GetTm (const int &NId) const
 
double GetMaxTm () const
 
double GetMinTm () const
 
void Add (const int &NId, const double &HitTm)
 
void Del (const int &NId)
 
bool IsNode (const int &NId) const
 
void Sort ()
 
bool operator< (const TCascade &Cascade) const
 
 TCascade ()
 
 TCascade (const double &alpha)
 
 TCascade (const double &alpha, const int &model)
 
 TCascade (const double &alpha, const double &eps)
 
 TCascade (const double &alpha, const int &model, const double &eps)
 
 TCascade (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
void Clr ()
 
int Len () const
 
int GetNode (const int &i) const
 
int GetParent (const int NId) const
 
double GetAlpha () const
 
double GetTm (const int &NId) const
 
void Add (const int &NId, const double &HitTm)
 
void Del (const int &NId)
 
bool IsNode (const int &NId) const
 
void Sort ()
 
double TransProb (const int &NId1, const int &NId2) const
 
double GetProb (const PNGraph &G)
 
void InitProb ()
 
double UpdateProb (const int &N1, const int &N2, const bool &UpdateProb=false)
 

Public Attributes

TInt CId
 
THash< TInt, THitInfoNIdHitH
 
TInt Model
 
TFlt CurProb
 
TFlt Alpha
 
TFlt Eps
 

Detailed Description

Definition at line 84 of file cascdynetinf.h.

Constructor & Destructor Documentation

TCascade::TCascade ( )
inline

Definition at line 90 of file cascdynetinf.h.

90 : CId(0), NIdHitH(), Model(0) { }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TInt CId
Definition: cascdynetinf.h:86
TCascade::TCascade ( const int &  model)
inline

Definition at line 91 of file cascdynetinf.h.

91 : NIdHitH() { Model = model; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TCascade::TCascade ( const int &  cid,
const int &  model 
)
inline

Definition at line 92 of file cascdynetinf.h.

92 : NIdHitH() { CId = cid; Model = model; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TInt CId
Definition: cascdynetinf.h:86
TCascade::TCascade ( TSIn SIn)
inline

Definition at line 93 of file cascdynetinf.h.

93 : CId(SIn), NIdHitH(SIn), Model(SIn) { }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TInt CId
Definition: cascdynetinf.h:86
TCascade::TCascade ( )
inline

Definition at line 26 of file cascnetinf.h.

26 : NIdHitH(), CurProb(0), Alpha(1.0), Eps(1e-64), Model(0) { }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TFlt Alpha
Definition: cascnetinf.h:23
TCascade::TCascade ( const double &  alpha)
inline

Definition at line 27 of file cascnetinf.h.

27 : NIdHitH(), CurProb(0), Alpha(alpha), Eps(1e-64), Model(0) { }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TFlt Alpha
Definition: cascnetinf.h:23
TCascade::TCascade ( const double &  alpha,
const int &  model 
)
inline

Definition at line 28 of file cascnetinf.h.

28 : NIdHitH(), CurProb(0), Alpha(alpha), Eps(1e-64), Model(model) { }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TFlt Alpha
Definition: cascnetinf.h:23
TCascade::TCascade ( const double &  alpha,
const double &  eps 
)
inline

Definition at line 29 of file cascnetinf.h.

29 : NIdHitH(), CurProb(0), Alpha(alpha), Eps(eps), Model(0) { }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TFlt Alpha
Definition: cascnetinf.h:23
TCascade::TCascade ( const double &  alpha,
const int &  model,
const double &  eps 
)
inline

Definition at line 30 of file cascnetinf.h.

30 : NIdHitH(), CurProb(0), Alpha(alpha), Eps(eps), Model(model) { }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TFlt Alpha
Definition: cascnetinf.h:23
TCascade::TCascade ( TSIn SIn)
inline

Definition at line 31 of file cascnetinf.h.

31 : NIdHitH(SIn), CurProb(SIn), Alpha(SIn) { }
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TFlt Alpha
Definition: cascnetinf.h:23

Member Function Documentation

void TCascade::Add ( const int &  NId,
const double &  HitTm 
)
inline

Definition at line 39 of file cascnetinf.h.

39 { NIdHitH.AddDat(NId, THitInfo(NId, HitTm)); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
void TCascade::Add ( const int &  NId,
const double &  HitTm 
)
inline

Definition at line 107 of file cascdynetinf.h.

107 { NIdHitH.AddDat(NId, THitInfo(NId, HitTm)); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
THash<TInt, THitInfo>::TIter TCascade::BegI ( ) const
inline

Definition at line 101 of file cascdynetinf.h.

101 { return NIdHitH.BegI(); }
TIter BegI() const
Definition: hash.h:171
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void TCascade::Clr ( )
inline

Definition at line 33 of file cascnetinf.h.

33 { NIdHitH.Clr(); CurProb = 0; Alpha = 1.0; }
TFlt CurProb
Definition: cascnetinf.h:23
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TFlt Alpha
Definition: cascnetinf.h:23
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:319
void TCascade::Clr ( )
inline

Definition at line 95 of file cascdynetinf.h.

95 { NIdHitH.Clr(); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:319
void TCascade::Del ( const int &  NId)
inline

Definition at line 40 of file cascnetinf.h.

40 { NIdHitH.DelKey(NId); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void DelKey(const TKey &Key)
Definition: hash.h:362
void TCascade::Del ( const int &  NId)
inline

Definition at line 108 of file cascdynetinf.h.

108 { NIdHitH.DelKey(NId); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void DelKey(const TKey &Key)
Definition: hash.h:362
THash<TInt, THitInfo>::TIter TCascade::EndI ( ) const
inline

Definition at line 102 of file cascdynetinf.h.

102 { return NIdHitH.EndI(); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TIter EndI() const
Definition: hash.h:176
double TCascade::GetAlpha ( ) const
inline

Definition at line 37 of file cascnetinf.h.

37 { return Alpha; }
TFlt Alpha
Definition: cascnetinf.h:23
int TCascade::GetId ( )
inline

Definition at line 96 of file cascdynetinf.h.

96 { return CId; }
TInt CId
Definition: cascdynetinf.h:86
double TCascade::GetMaxTm ( ) const
inline

Definition at line 105 of file cascdynetinf.h.

105 { return NIdHitH[NIdHitH.Len()-1].Tm; } // we assume the cascade is sorted
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int Len() const
Definition: hash.h:186
double TCascade::GetMinTm ( ) const
inline

Definition at line 106 of file cascdynetinf.h.

106 { return NIdHitH[0].Tm; } // we assume the cascade is sorted
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int TCascade::GetModel ( ) const
inline

Definition at line 103 of file cascdynetinf.h.

103 { return Model; }
TInt Model
Definition: cascdynetinf.h:88
int TCascade::GetNode ( const int &  i) const
inline

Definition at line 35 of file cascnetinf.h.

35 { return NIdHitH.GetKey(i); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
int TCascade::GetNode ( const int &  i) const
inline

Definition at line 100 of file cascdynetinf.h.

100 { return NIdHitH.GetKey(i); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
int TCascade::GetParent ( const int  NId) const
inline

Definition at line 36 of file cascnetinf.h.

36 { return NIdHitH.GetDat(NId).Parent; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TInt Parent
Definition: cascnetinf.h:9
double TCascade::GetProb ( const PNGraph G)

Definition at line 17 of file cascnetinf.cpp.

17  {
18  double P = 0;
19  for (int n = 0; n < Len(); n++) {
20  const int DstNId = GetNode(n);
21  const double DstTm = GetTm(DstNId);
22  TNGraph::TNodeI NI = G->GetNI(DstNId);
23  double MxProb = log(Eps);
24  int BestParent = -1;
25  for (int e = 0; e < NI.GetInDeg(); e++) {
26  const int SrcNId = NI.GetInNId(e);
27  if (IsNode(SrcNId) && GetTm(SrcNId) < DstTm) {
28  const double Prob = log(TransProb(SrcNId, DstNId));
29  if (MxProb < Prob) { MxProb = Prob; BestParent = SrcNId; }
30  }
31  }
32  NIdHitH.GetDat(DstNId).Parent = BestParent;
33  P += MxProb;
34  }
35 
36  return P;
37 }
TFlt Eps
Definition: cascnetinf.h:23
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: graph.h:483
int Len() const
Definition: cascdynetinf.h:97
double TransProb(const int &NId1, const int &NId2) const
Definition: cascnetinf.cpp:4
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
double GetTm(const int &NId) const
Definition: cascdynetinf.h:104
TInt Parent
Definition: cascnetinf.h:9
Node iterator. Only forward iteration (operator++) is supported.
Definition: graph.h:339
int GetNode(const int &i) const
Definition: cascdynetinf.h:100
int GetInDeg() const
Returns in-degree of the current node.
Definition: graph.h:360
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
Definition: graph.h:368
bool IsNode(const int &NId) const
Definition: cascdynetinf.h:109
double TCascade::GetTm ( const int &  NId) const
inline

Definition at line 38 of file cascnetinf.h.

38 { return NIdHitH.GetDat(NId).Tm; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
double TCascade::GetTm ( const int &  NId) const
inline

Definition at line 104 of file cascdynetinf.h.

104 { return NIdHitH.GetDat(NId).Tm; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
void TCascade::InitProb ( )

Definition at line 40 of file cascnetinf.cpp.

40  {
41  CurProb = log(Eps) * Len();
42  for (int i = 0; i < Len(); i++) {
43  NIdHitH[i].Parent = -1; }
44 }
TFlt Eps
Definition: cascnetinf.h:23
TFlt CurProb
Definition: cascnetinf.h:23
int Len() const
Definition: cascdynetinf.h:97
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
bool TCascade::IsNode ( const int &  NId) const
inline

Definition at line 41 of file cascnetinf.h.

41 { return NIdHitH.IsKey(NId); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
bool IsKey(const TKey &Key) const
Definition: hash.h:216
bool TCascade::IsNode ( const int &  NId) const
inline

Definition at line 109 of file cascdynetinf.h.

109 { return NIdHitH.IsKey(NId); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
bool IsKey(const TKey &Key) const
Definition: hash.h:216
int TCascade::Len ( ) const
inline

Definition at line 34 of file cascnetinf.h.

34 { return NIdHitH.Len(); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int Len() const
Definition: hash.h:186
int TCascade::Len ( ) const
inline

Definition at line 97 of file cascdynetinf.h.

97 { return NIdHitH.Len(); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int Len() const
Definition: hash.h:186
int TCascade::LenAfterT ( const double &  T)
inline

Definition at line 99 of file cascdynetinf.h.

99 { int len = 0; while (len < NIdHitH.Len() && NIdHitH[NIdHitH.Len()-1-len].Tm >= T) { len++; } return len; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int Len() const
Definition: hash.h:186
int TCascade::LenBeforeT ( const double &  T)
inline

Definition at line 98 of file cascdynetinf.h.

98 { int len = 0; while (len < NIdHitH.Len() && NIdHitH[len].Tm <= T) { len++; } return len; }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
int Len() const
Definition: hash.h:186
bool TCascade::operator< ( const TCascade Cascade) const
inline

Definition at line 111 of file cascdynetinf.h.

111  {
112  return Len() < Cascade.Len(); }
int Len() const
Definition: cascdynetinf.h:97
void TCascade::Save ( TSOut SOut) const
inline

Definition at line 32 of file cascnetinf.h.

32 { NIdHitH.Save(SOut); CurProb.Save(SOut); Alpha.Save(SOut); }
TFlt CurProb
Definition: cascnetinf.h:23
void Save(TSOut &SOut) const
Definition: hash.h:141
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TFlt Alpha
Definition: cascnetinf.h:23
void Save(TSOut &SOut) const
Definition: dt.h:1309
void TCascade::Save ( TSOut SOut) const
inline

Definition at line 94 of file cascdynetinf.h.

94 { CId.Save(SOut); NIdHitH.Save(SOut); Model.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1060
void Save(TSOut &SOut) const
Definition: hash.h:141
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
TInt Model
Definition: cascdynetinf.h:88
TInt CId
Definition: cascdynetinf.h:86
void TCascade::Sort ( )
inline

Definition at line 42 of file cascnetinf.h.

42 { NIdHitH.SortByDat(true); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void SortByDat(const bool &Asc=true)
Definition: hash.h:250
void TCascade::Sort ( )
inline

Definition at line 110 of file cascdynetinf.h.

110 { NIdHitH.SortByDat(true); }
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
void SortByDat(const bool &Asc=true)
Definition: hash.h:250
double TCascade::TransProb ( const int &  NId1,
const int &  NId2 
) const

Definition at line 4 of file cascnetinf.cpp.

4  {
5  if (!IsNode(NId1) || !IsNode(NId2)) { return Eps.Val; }
6  if (GetTm(NId1) >= GetTm(NId2)) { return Eps.Val; }
7  if (Model==0)
8  return Alpha*exp(-Alpha*(GetTm(NId2)-GetTm(NId1))); // exponential
9  else if (Model==1)
10  return (Alpha-1)*pow((GetTm(NId2)-GetTm(NId1)), -Alpha); // power-law
11  else
12  return Alpha*(GetTm(NId2)-GetTm(NId1))*exp(-0.5*Alpha*pow(GetTm(NId2)-GetTm(NId1), 2)); // rayleigh
13 
14  return (-1);
15 }
TFlt Eps
Definition: cascnetinf.h:23
double Val
Definition: dt.h:1295
TInt Model
Definition: cascdynetinf.h:88
double GetTm(const int &NId) const
Definition: cascdynetinf.h:104
TFlt Alpha
Definition: cascnetinf.h:23
bool IsNode(const int &NId) const
Definition: cascdynetinf.h:109
double TCascade::UpdateProb ( const int &  N1,
const int &  N2,
const bool &  UpdateProb = false 
)

Definition at line 47 of file cascnetinf.cpp.

47  {
48  if (!IsNode(N1) || !IsNode(N2)) { return CurProb; }
49  if (GetTm(N1) >= GetTm(N2)) { return CurProb; }
50  const double P1 = log(TransProb(GetParent(N2), N2));
51  const double P2 = log(TransProb(N1, N2)); // N1 influences N2
52  if (P1 < P2) {
53  if (UpdateProb) { // the edge is there, update the CurProb and best Parent
54  CurProb = CurProb - P1 + P2;
55  NIdHitH.GetDat(N2).Parent = N1;
56  } else {
57  return CurProb - P1 + P2; }
58  }
59  return CurProb;
60 }
TFlt CurProb
Definition: cascnetinf.h:23
int GetParent(const int NId) const
Definition: cascnetinf.h:36
double TransProb(const int &NId1, const int &NId2) const
Definition: cascnetinf.cpp:4
THash< TInt, THitInfo > NIdHitH
Definition: cascdynetinf.h:87
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
double UpdateProb(const int &N1, const int &N2, const bool &UpdateProb=false)
Definition: cascnetinf.cpp:47
double GetTm(const int &NId) const
Definition: cascdynetinf.h:104
TInt Parent
Definition: cascnetinf.h:9
bool IsNode(const int &NId) const
Definition: cascdynetinf.h:109

Member Data Documentation

TFlt TCascade::Alpha

Definition at line 23 of file cascnetinf.h.

TInt TCascade::CId

Definition at line 86 of file cascdynetinf.h.

TFlt TCascade::CurProb

Definition at line 23 of file cascnetinf.h.

TFlt TCascade::Eps

Definition at line 23 of file cascnetinf.h.

TInt TCascade::Model

Definition at line 88 of file cascdynetinf.h.

THash< TInt, THitInfo > TCascade::NIdHitH

Definition at line 87 of file cascdynetinf.h.


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