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

#include <cascdynetinf.h>

Collaboration diagram for TCascade:

List of all members.

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.

: CId(0), NIdHitH(), Model(0) { }
TCascade::TCascade ( const int &  model) [inline]

Definition at line 91 of file cascdynetinf.h.

References Model.

: NIdHitH() { Model = model; }
TCascade::TCascade ( const int &  cid,
const int &  model 
) [inline]

Definition at line 92 of file cascdynetinf.h.

References CId, and Model.

: NIdHitH() { CId = cid; Model = model; }
TCascade::TCascade ( TSIn SIn) [inline]

Definition at line 93 of file cascdynetinf.h.

: CId(SIn), NIdHitH(SIn), Model(SIn) { }
TCascade::TCascade ( ) [inline]

Definition at line 26 of file cascnetinf.h.

: NIdHitH(), CurProb(0), Alpha(1.0), Eps(1e-64), Model(0) { }
TCascade::TCascade ( const double &  alpha) [inline]

Definition at line 27 of file cascnetinf.h.

: NIdHitH(), CurProb(0), Alpha(alpha), Eps(1e-64), Model(0) { }
TCascade::TCascade ( const double &  alpha,
const int &  model 
) [inline]

Definition at line 28 of file cascnetinf.h.

: NIdHitH(), CurProb(0), Alpha(alpha), Eps(1e-64), Model(model) { }
TCascade::TCascade ( const double &  alpha,
const double &  eps 
) [inline]

Definition at line 29 of file cascnetinf.h.

: NIdHitH(), CurProb(0), Alpha(alpha), Eps(eps), Model(0) { }
TCascade::TCascade ( const double &  alpha,
const int &  model,
const double &  eps 
) [inline]

Definition at line 30 of file cascnetinf.h.

: NIdHitH(), CurProb(0), Alpha(alpha), Eps(eps), Model(model) { }
TCascade::TCascade ( TSIn SIn) [inline]

Definition at line 31 of file cascnetinf.h.

: NIdHitH(SIn), CurProb(SIn), Alpha(SIn) { }

Member Function Documentation

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.

{ NIdHitH.AddDat(NId, THitInfo(NId, HitTm)); }

Here is the call graph for this function:

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

{ NIdHitH.AddDat(NId, THitInfo(NId, HitTm)); }

Here is the call graph for this function:

Here is the caller graph for this function:

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

{ return NIdHitH.BegI(); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TCascade::Clr ( ) [inline]

Definition at line 33 of file cascnetinf.h.

References Alpha, THash< TKey, TDat, THashFunc >::Clr(), CurProb, and NIdHitH.

{ NIdHitH.Clr(); CurProb = 0; Alpha = 1.0; }

Here is the call graph for this function:

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

{ NIdHitH.Clr(); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TCascade::Del ( const int &  NId) [inline]

Definition at line 40 of file cascnetinf.h.

References THash< TKey, TDat, THashFunc >::DelKey(), and NIdHitH.

{ NIdHitH.DelKey(NId); }

Here is the call graph for this function:

void TCascade::Del ( const int &  NId) [inline]

Definition at line 108 of file cascdynetinf.h.

References THash< TKey, TDat, THashFunc >::DelKey(), and NIdHitH.

{ NIdHitH.DelKey(NId); }

Here is the call graph for this function:

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

{ return NIdHitH.EndI(); }

Here is the call graph for this function:

Here is the caller graph for this function:

double TCascade::GetAlpha ( ) const [inline]

Definition at line 37 of file cascnetinf.h.

References Alpha.

{ return Alpha; }
int TCascade::GetId ( ) [inline]

Definition at line 96 of file cascdynetinf.h.

References CId.

{ return CId; }
double TCascade::GetMaxTm ( ) const [inline]

Definition at line 105 of file cascdynetinf.h.

References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.

{ return NIdHitH[NIdHitH.Len()-1].Tm; } // we assume the cascade is sorted

Here is the call graph for this function:

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

Here is the caller graph for this function:

int TCascade::GetModel ( ) const [inline]

Definition at line 103 of file cascdynetinf.h.

References Model.

{ return Model; }
int TCascade::GetNode ( const int &  i) const [inline]

Definition at line 35 of file cascnetinf.h.

References THash< TKey, TDat, THashFunc >::GetKey(), and NIdHitH.

{ return NIdHitH.GetKey(i); }

Here is the call graph for this function:

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

{ return NIdHitH.GetKey(i); }

Here is the call graph for this function:

Here is the caller graph for this function:

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

{ return NIdHitH.GetDat(NId).Parent; }

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Here is the call graph for this function:

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.

{ return NIdHitH.GetDat(NId).Tm; }

Here is the call graph for this function:

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

{ return NIdHitH.GetDat(NId).Tm; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file cascnetinf.cpp.

References CurProb, Eps, Len(), and NIdHitH.

                        {
    CurProb = log(Eps) * Len();
    for (int i = 0; i < Len(); i++) {
      NIdHitH[i].Parent = -1; }
}

Here is the call graph for this function:

bool TCascade::IsNode ( const int &  NId) const [inline]

Definition at line 41 of file cascnetinf.h.

References THash< TKey, TDat, THashFunc >::IsKey(), and NIdHitH.

{ return NIdHitH.IsKey(NId); }

Here is the call graph for this function:

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

{ return NIdHitH.IsKey(NId); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TCascade::Len ( ) const [inline]

Definition at line 34 of file cascnetinf.h.

References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.

{ return NIdHitH.Len(); }

Here is the call graph for this function:

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

{ return NIdHitH.Len(); }

Here is the call graph for this function:

Here is the caller graph for this function:

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; }

Here is the call graph for this function:

int TCascade::LenBeforeT ( const double &  T) [inline]

Definition at line 98 of file cascdynetinf.h.

References THash< TKey, TDat, THashFunc >::Len(), and NIdHitH.

{ int len = 0; while (len < NIdHitH.Len() && NIdHitH[len].Tm <= T) { len++; } return len; }

Here is the call graph for this function:

bool TCascade::operator< ( const TCascade Cascade) const [inline]

Definition at line 111 of file cascdynetinf.h.

References Len().

                                                  {
      return Len() < Cascade.Len(); }

Here is the call graph for this function:

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

{ NIdHitH.Save(SOut); CurProb.Save(SOut); Alpha.Save(SOut); }

Here is the call graph for this function:

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

{ CId.Save(SOut); NIdHitH.Save(SOut); Model.Save(SOut); }

Here is the call graph for this function:

void TCascade::Sort ( ) [inline]

Definition at line 42 of file cascnetinf.h.

References NIdHitH, and THash< TKey, TDat, THashFunc >::SortByDat().

{ NIdHitH.SortByDat(true); }

Here is the call graph for this function:

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

{ NIdHitH.SortByDat(true); }

Here is the call graph for this function:

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Here is the call graph for this function:


Member Data Documentation

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


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