SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#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, THitInfo > | NIdHitH |
TInt | Model |
TFlt | CurProb |
TFlt | Alpha |
TFlt | Eps |
Definition at line 84 of file cascdynetinf.h.
TCascade::TCascade | ( | ) | [inline] |
Definition at line 90 of file cascdynetinf.h.
TCascade::TCascade | ( | const int & | model | ) | [inline] |
TCascade::TCascade | ( | const int & | cid, |
const int & | model | ||
) | [inline] |
TCascade::TCascade | ( | TSIn & | SIn | ) | [inline] |
Definition at line 93 of file cascdynetinf.h.
TCascade::TCascade | ( | ) | [inline] |
TCascade::TCascade | ( | const double & | alpha | ) | [inline] |
TCascade::TCascade | ( | const double & | alpha, |
const int & | model | ||
) | [inline] |
TCascade::TCascade | ( | const double & | alpha, |
const double & | eps | ||
) | [inline] |
TCascade::TCascade | ( | const double & | alpha, |
const int & | model, | ||
const double & | eps | ||
) | [inline] |
TCascade::TCascade | ( | TSIn & | SIn | ) | [inline] |
Definition at line 31 of file cascnetinf.h.
void TCascade::Add | ( | const int & | NId, |
const double & | HitTm | ||
) | [inline] |
Definition at line 39 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::AddDat(), and NIdHitH.
void TCascade::Add | ( | const int & | NId, |
const double & | HitTm | ||
) | [inline] |
Definition at line 107 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::AddDat(), and NIdHitH.
Referenced by TNetInfBs::AddCasc(), TNIBs::AddCasc(), TNetInfBs::GenCascade(), and TNIBs::GenCascade().
THash<TInt, THitInfo>::TIter TCascade::BegI | ( | ) | const [inline] |
Definition at line 101 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::BegI(), and NIdHitH.
Referenced by TNIBs::UpdateDiff().
void TCascade::Clr | ( | ) | [inline] |
Definition at line 33 of file cascnetinf.h.
References Alpha, THash< TKey, TDat, THashFunc >::Clr(), CurProb, and NIdHitH.
void TCascade::Clr | ( | ) | [inline] |
Definition at line 95 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::Clr(), and NIdHitH.
Referenced by TNetInfBs::GenCascade(), and TNIBs::GenCascade().
void TCascade::Del | ( | const int & | NId | ) | [inline] |
Definition at line 40 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::DelKey(), and NIdHitH.
void TCascade::Del | ( | const int & | NId | ) | [inline] |
Definition at line 108 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::DelKey(), and NIdHitH.
THash<TInt, THitInfo>::TIter TCascade::EndI | ( | ) | const [inline] |
Definition at line 102 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::EndI(), and NIdHitH.
Referenced by TNIBs::UpdateDiff().
double TCascade::GetAlpha | ( | ) | const [inline] |
int TCascade::GetId | ( | ) | [inline] |
double TCascade::GetMaxTm | ( | ) | const [inline] |
Definition at line 105 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.
double TCascade::GetMinTm | ( | ) | const [inline] |
Definition at line 106 of file cascdynetinf.h.
References NIdHitH.
Referenced by TNIBs::UpdateDiff().
{ return NIdHitH[0].Tm; } // we assume the cascade is sorted
int TCascade::GetModel | ( | ) | const [inline] |
int TCascade::GetNode | ( | const int & | i | ) | const [inline] |
Definition at line 35 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::GetKey(), and NIdHitH.
int TCascade::GetNode | ( | const int & | i | ) | const [inline] |
Definition at line 100 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::GetKey(), and NIdHitH.
Referenced by GetProb().
int TCascade::GetParent | ( | const int | NId | ) | const [inline] |
Definition at line 36 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::GetDat(), NIdHitH, and THitInfo::Parent.
Referenced by UpdateProb().
double TCascade::GetProb | ( | const PNGraph & | G | ) |
Definition at line 17 of file cascnetinf.cpp.
References Eps, THash< TKey, TDat, THashFunc >::GetDat(), TNGraph::TNodeI::GetInDeg(), TNGraph::TNodeI::GetInNId(), TNGraph::GetNI(), GetNode(), GetTm(), IsNode(), Len(), NIdHitH, THitInfo::Parent, and TransProb().
{ double P = 0; for (int n = 0; n < Len(); n++) { const int DstNId = GetNode(n); const double DstTm = GetTm(DstNId); TNGraph::TNodeI NI = G->GetNI(DstNId); double MxProb = log(Eps); int BestParent = -1; for (int e = 0; e < NI.GetInDeg(); e++) { const int SrcNId = NI.GetInNId(e); if (IsNode(SrcNId) && GetTm(SrcNId) < DstTm) { const double Prob = log(TransProb(SrcNId, DstNId)); if (MxProb < Prob) { MxProb = Prob; BestParent = SrcNId; } } } NIdHitH.GetDat(DstNId).Parent = BestParent; P += MxProb; } return P; }
double TCascade::GetTm | ( | const int & | NId | ) | const [inline] |
Definition at line 38 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::GetDat(), NIdHitH, and THitInfo::Tm.
double TCascade::GetTm | ( | const int & | NId | ) | const [inline] |
Definition at line 104 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::GetDat(), NIdHitH, and THitInfo::Tm.
Referenced by GetProb(), TransProb(), TNIBs::UpdateDiff(), and UpdateProb().
void TCascade::InitProb | ( | ) |
bool TCascade::IsNode | ( | const int & | NId | ) | const [inline] |
Definition at line 41 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::IsKey(), and NIdHitH.
bool TCascade::IsNode | ( | const int & | NId | ) | const [inline] |
Definition at line 109 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::IsKey(), and NIdHitH.
Referenced by GetProb(), TransProb(), TNIBs::UpdateDiff(), and UpdateProb().
int TCascade::Len | ( | ) | const [inline] |
Definition at line 34 of file cascnetinf.h.
References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.
int TCascade::Len | ( | ) | const [inline] |
Definition at line 97 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.
Referenced by TNetInfBs::GenCascade(), TNIBs::GenCascade(), GetProb(), InitProb(), operator<(), and TNetInfBs::SaveCascades().
int TCascade::LenAfterT | ( | const double & | T | ) | [inline] |
Definition at line 99 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.
{ int len = 0; while (len < NIdHitH.Len() && NIdHitH[NIdHitH.Len()-1-len].Tm >= T) { len++; } return len; }
int TCascade::LenBeforeT | ( | const double & | T | ) | [inline] |
Definition at line 98 of file cascdynetinf.h.
References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.
bool TCascade::operator< | ( | const TCascade & | Cascade | ) | const [inline] |
Definition at line 111 of file cascdynetinf.h.
References Len().
void TCascade::Save | ( | TSOut & | SOut | ) | const [inline] |
Definition at line 32 of file cascnetinf.h.
References Alpha, CurProb, NIdHitH, THash< TKey, TDat, THashFunc >::Save(), and TFlt::Save().
void TCascade::Save | ( | TSOut & | SOut | ) | const [inline] |
Definition at line 94 of file cascdynetinf.h.
References CId, Model, NIdHitH, THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().
void TCascade::Sort | ( | ) | [inline] |
Definition at line 42 of file cascnetinf.h.
References NIdHitH, and THash< TKey, TDat, THashFunc >::SortByDat().
void TCascade::Sort | ( | ) | [inline] |
Definition at line 110 of file cascdynetinf.h.
References NIdHitH, and THash< TKey, TDat, THashFunc >::SortByDat().
Referenced by TNetInfBs::AddCasc(), TNIBs::AddCasc(), TNetInfBs::GenCascade(), and TNIBs::GenCascade().
double TCascade::TransProb | ( | const int & | NId1, |
const int & | NId2 | ||
) | const |
Definition at line 4 of file cascnetinf.cpp.
References Alpha, Eps, GetTm(), IsNode(), Model, and TFlt::Val.
Referenced by GetProb(), and UpdateProb().
{ if (!IsNode(NId1) || !IsNode(NId2)) { return Eps.Val; } if (GetTm(NId1) >= GetTm(NId2)) { return Eps.Val; } if (Model==0) return Alpha*exp(-Alpha*(GetTm(NId2)-GetTm(NId1))); // exponential else if (Model==1) return (Alpha-1)*pow((GetTm(NId2)-GetTm(NId1)), -Alpha); // power-law else return Alpha*(GetTm(NId2)-GetTm(NId1))*exp(-0.5*Alpha*pow(GetTm(NId2)-GetTm(NId1), 2)); // rayleigh return (-1); }
double TCascade::UpdateProb | ( | const int & | N1, |
const int & | N2, | ||
const bool & | UpdateProb = false |
||
) |
Definition at line 47 of file cascnetinf.cpp.
References CurProb, THash< TKey, TDat, THashFunc >::GetDat(), GetParent(), GetTm(), IsNode(), NIdHitH, THitInfo::Parent, and TransProb().
{ if (!IsNode(N1) || !IsNode(N2)) { return CurProb; } if (GetTm(N1) >= GetTm(N2)) { return CurProb; } const double P1 = log(TransProb(GetParent(N2), N2)); const double P2 = log(TransProb(N1, N2)); // N1 influences N2 if (P1 < P2) { if (UpdateProb) { // the edge is there, update the CurProb and best Parent CurProb = CurProb - P1 + P2; NIdHitH.GetDat(N2).Parent = N1; } else { return CurProb - P1 + P2; } } return CurProb; }
Definition at line 23 of file cascnetinf.h.
Referenced by Clr(), GetAlpha(), Save(), and TransProb().
Definition at line 86 of file cascdynetinf.h.
Referenced by TNIBs::AddCasc(), GetId(), Save(), and TCascade().
Definition at line 23 of file cascnetinf.h.
Referenced by Clr(), InitProb(), Save(), and UpdateProb().
Definition at line 23 of file cascnetinf.h.
Referenced by GetProb(), InitProb(), and TransProb().
Definition at line 88 of file cascdynetinf.h.
Referenced by GetModel(), Save(), TCascade(), and TransProb().
Definition at line 87 of file cascdynetinf.h.
Referenced by Add(), BegI(), Clr(), Del(), EndI(), GetMaxTm(), GetMinTm(), GetNode(), GetParent(), GetProb(), GetTm(), InitProb(), IsNode(), Len(), LenAfterT(), LenBeforeT(), Save(), TNetInfBs::SaveCascades(), TNIBs::SaveCascades(), Sort(), and UpdateProb().