Simulates a single Forest Fire on a directed graph starting for a given starting node. For more details is "Graph Evolution: Densification and Shrinking Diameters" by J. Leskovec, J. Kleinberg, C. Faloutsos. ACM Transactions on Knowledge Discovery from Data (TKDD), 1(1), 2007. 
Definition at line 6 of file ff.h.
 
      
        
          | void TForestFire::BurnExpFire  | 
          ( | 
           | ) | 
           | 
        
      
 
Definition at line 21 of file ff.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), BckBurnProb, BurnedNIdV, TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::Empty(), FwdBurnProb, TVec< TVal, TSizeTy >::Gen(), TNGraph::TNodeI::GetInDeg(), TNGraph::TNodeI::GetInNId(), THash< TKey, TDat, THashFunc >::GetKey(), TNGraph::GetNI(), TNGraph::TNodeI::GetOutDeg(), TNGraph::TNodeI::GetOutNId(), TRnd::GetUniDev(), Graph, InfectNIdV, THash< TKey, TDat, THashFunc >::IsKey(), THash< TKey, TDat, THashFunc >::Len(), TVec< TVal, TSizeTy >::Len(), NBurnedTmV, NBurningTmV, NewBurnedTmV, ProbDecay, Rnd, and TVec< TVal, TSizeTy >::Swap().
Referenced by TFfGGen::AddNodes().
   30   int NBurned = NInfect, NDiedFire=0;
 
   34   for (
int time = 0; ; time++) {
 
   35     NewBurnedNIdV.
Clr(
false);
 
   37     for (
int node = 0; node < BurningNIdV.
Len(); node++) {
 
   38       const int& BurningNId = BurningNIdV[node];
 
   43       for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
   45         if (! BurnedNIdH.
IsKey(OutNId)) { 
 
   48             BurnedNIdH.
AddDat(OutNId);  NewBurnedNIdV.
Add(OutNId);  NBurned++; }
 
   53         for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
   55           if (! BurnedNIdH.
IsKey(InNId)) { 
 
   58               BurnedNIdH.
AddDat(InNId);  NewBurnedNIdV.
Add(InNId);  NBurned++; }
 
   62       if (! HasAliveNbrs) { NDiedFire++; }
 
   68     BurningNIdV.
Swap(NewBurnedNIdV);    
 
   69     if (BurningNIdV.
Empty()) 
break;
 
   74   for (
int i = 0; i < BurnedNIdH.
Len(); i++) {
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
TSizeTy Len() const 
Returns the number of elements in the vector. 
 
bool Empty() const 
Tests whether the vector is empty. 
 
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec. 
 
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector. 
 
int GetOutDeg() const 
Returns out-degree of the current node. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements. 
 
int GetInDeg() const 
Returns in-degree of the current node. 
 
bool IsKey(const TKey &Key) const 
 
int GetInNId(const int &NodeN) const 
Returns ID of NodeN-th in-node (the node pointing to the current node). 
 
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element. 
 
TDat & AddDat(const TKey &Key)
 
int GetOutNId(const int &NodeN) const 
Returns ID of NodeN-th out-node (the node the current node points to). 
 
const TKey & GetKey(const int &KeyId) const 
 
 
 
 
      
        
          | void TForestFire::BurnGeoFire  | 
          ( | 
           | ) | 
           | 
        
      
 
Definition at line 82 of file ff.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), BckBurnProb, BurnedNIdV, TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::Empty(), FwdBurnProb, TVec< TVal, TSizeTy >::Gen(), TRnd::GetGeoDev(), TNGraph::TNodeI::GetInDeg(), TNGraph::TNodeI::GetInNId(), THash< TKey, TDat, THashFunc >::GetKey(), TNGraph::GetNI(), TNGraph::TNodeI::GetOutDeg(), TNGraph::TNodeI::GetOutNId(), Graph, InfectNIdV, THash< TKey, TDat, THashFunc >::IsKey(), THash< TKey, TDat, THashFunc >::Len(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), NBurnedTmV, NBurningTmV, NewBurnedTmV, ProbDecay, Rnd, TVec< TVal, TSizeTy >::Shuffle(), and TVec< TVal, TSizeTy >::Swap().
Referenced by TFfGGen::AddNodes().
   90   bool HasAliveInNbrs, HasAliveOutNbrs; 
 
   92   int NBurned = NInfect, time;
 
   96   for (time = 0; ; time++) {
 
   97     NewBurnedNIdV.
Clr(
false);
 
   98     for (
int node = 0; node < BurningNIdV.
Len(); node++) {
 
   99       const int& BurningNId = BurningNIdV[node];
 
  102       HasAliveOutNbrs = 
false;
 
  103       AliveNIdV.
Clr(
false); 
 
  104       for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  106         if (! BurnedNIdH.
IsKey(OutNId)) {
 
  107           HasAliveOutNbrs = 
true;  AliveNIdV.
Add(OutNId); }
 
  111       if (HasAliveOutNbrs && BurnNFwdLinks > 0) {
 
  113         for (
int i = 0; i < 
TMath::Mn(BurnNFwdLinks, AliveNIdV.
Len()); i++) {
 
  114           BurnedNIdH.
AddDat(AliveNIdV[i]);
 
  115           NewBurnedNIdV.
Add(AliveNIdV[i]);  NBurned++; }
 
  120         HasAliveInNbrs = 
false;
 
  121         AliveNIdV.
Clr(
false);
 
  122         for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
  124           if (! BurnedNIdH.
IsKey(InNId)) {
 
  125             HasAliveInNbrs = 
true;  AliveNIdV.
Add(InNId); }
 
  129         if (HasAliveInNbrs && BurnNBckLinks > 0) {
 
  131           for (
int i = 0; i < 
TMath::Mn(BurnNBckLinks, AliveNIdV.
Len()); i++) {
 
  132             BurnedNIdH.
AddDat(AliveNIdV[i]);
 
  133             NewBurnedNIdV.
Add(AliveNIdV[i]);  NBurned++; }
 
  139     BurningNIdV.
Swap(NewBurnedNIdV);   
 
  140     if (BurningNIdV.
Empty()) 
break;
 
  145   for (
int i = 0; i < BurnedNIdH.
Len(); i++) {
 
static const T & Mn(const T &LVal, const T &RVal)
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
TSizeTy Len() const 
Returns the number of elements in the vector. 
 
bool Empty() const 
Tests whether the vector is empty. 
 
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec. 
 
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector. 
 
int GetOutDeg() const 
Returns out-degree of the current node. 
 
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements. 
 
int GetGeoDev(const double &Prb)
 
int GetInDeg() const 
Returns in-degree of the current node. 
 
bool IsKey(const TKey &Key) const 
 
int GetInNId(const int &NodeN) const 
Returns ID of NodeN-th in-node (the node pointing to the current node). 
 
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element. 
 
TDat & AddDat(const TKey &Key)
 
int GetOutNId(const int &NodeN) const 
Returns ID of NodeN-th out-node (the node the current node points to). 
 
const TKey & GetKey(const int &KeyId) const