SNAP Library 4.1, User Reference  2018-07-26 16:30:42
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
ThreeTEdgeTriadCounter Class Reference

#include <temporalmotifs.h>

Inherits StarTriad3TEdgeCounter< TriadEdgeData >.

Public Member Functions

 ThreeTEdgeTriadCounter (int max_nodes, int node_u, int node_v)
 
int Counts (int dir1, int dir2, int dir3)
 
- Public Member Functions inherited from StarTriad3TEdgeCounter< TriadEdgeData >
 StarTriad3TEdgeCounter ()
 
void Count (const TVec< TriadEdgeData > &events, const TIntV &timestamps, double delta)
 

Protected Member Functions

void InitializeCounters ()
 
void PopPre (const TriadEdgeData &event)
 
void PopPos (const TriadEdgeData &event)
 
void PushPre (const TriadEdgeData &event)
 
void PushPos (const TriadEdgeData &event)
 
void ProcessCurrent (const TriadEdgeData &event)
 
bool IsEdgeNode (int nbr)
 

Private Attributes

int max_nodes_
 
Counter3D pre_sum_
 
Counter3D pos_sum_
 
Counter3D mid_sum_
 
Counter3D triad_counts_
 
Counter3D pre_nodes_
 
Counter3D pos_nodes_
 
int node_u_
 
int node_v_
 

Detailed Description

Definition at line 269 of file temporalmotifs.h.

Constructor & Destructor Documentation

ThreeTEdgeTriadCounter::ThreeTEdgeTriadCounter ( int  max_nodes,
int  node_u,
int  node_v 
)
inline

Definition at line 275 of file temporalmotifs.h.

275  :
276  max_nodes_(max_nodes), node_u_(node_u), node_v_(node_v) {}

Member Function Documentation

int ThreeTEdgeTriadCounter::Counts ( int  dir1,
int  dir2,
int  dir3 
)
inline

Definition at line 279 of file temporalmotifs.h.

279 { return triad_counts_(dir1, dir2, dir3); }
void ThreeTEdgeTriadCounter::InitializeCounters ( )
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 693 of file temporalmotifs.cpp.

693  {
696  pre_sum_ = Counter3D(2, 2, 2);
697  pos_sum_ = Counter3D(2, 2, 2);
698  mid_sum_ = Counter3D(2, 2, 2);
699  triad_counts_ = Counter3D(2, 2, 2);
700 }
bool ThreeTEdgeTriadCounter::IsEdgeNode ( int  nbr)
inlineprotected

Definition at line 288 of file temporalmotifs.h.

288 { return nbr == node_u_ || nbr == node_v_; }
void ThreeTEdgeTriadCounter::PopPos ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 714 of file temporalmotifs.cpp.

714  {
715  int nbr = event.nbr;
716  int dir = event.dir;
717  int u_or_v = event.u_or_v;
718  if (!IsEdgeNode(nbr)) {
719  pos_nodes_(dir, u_or_v, nbr) -= 1;
720  for (int i = 0; i < 2; i++) {
721  pos_sum_(u_or_v, dir, i) -= pos_nodes_(i, 1 - u_or_v, nbr);
722  }
723  }
724 }
bool IsEdgeNode(int nbr)
void ThreeTEdgeTriadCounter::PopPre ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 702 of file temporalmotifs.cpp.

702  {
703  int nbr = event.nbr;
704  int dir = event.dir;
705  int u_or_v = event.u_or_v;
706  if (!IsEdgeNode(nbr)) {
707  pre_nodes_(dir, u_or_v, nbr) -= 1;
708  for (int i = 0; i < 2; i++) {
709  pre_sum_(u_or_v, dir, i) -= pre_nodes_(i, 1 - u_or_v, nbr);
710  }
711  }
712 }
bool IsEdgeNode(int nbr)
void ThreeTEdgeTriadCounter::ProcessCurrent ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 750 of file temporalmotifs.cpp.

750  {
751  int nbr = event.nbr;
752  int dir = event.dir;
753  int u_or_v = event.u_or_v;
754  // Adjust middle sums
755  if (!IsEdgeNode(nbr)) {
756  for (int i = 0; i < 2; i++) {
757  mid_sum_(1 - u_or_v, i, dir) -= pre_nodes_(i, 1 - u_or_v, nbr);
758  mid_sum_(u_or_v, dir, i) += pos_nodes_(i, 1 - u_or_v, nbr);
759  }
760  }
761  // Update counts
762  if (IsEdgeNode(nbr)) {
763  // Determine if the event edge is u --> v or v --> u
764  int u_to_v = 0;
765  if (((nbr == node_u_) && dir == 0) || ((nbr == node_v_) && dir == 1)) {
766  u_to_v = 1;
767  }
768  // i --> j, k --> j, i --> k
769  triad_counts_(0, 0, 0) += mid_sum_(u_to_v, 0, 0)
770  + pos_sum_(u_to_v, 0, 1)
771  + pre_sum_(1 - u_to_v, 1, 1);
772  // i --> j, k --> i, j --> k
773  triad_counts_(1, 0, 0) += mid_sum_(u_to_v, 1, 0)
774  + pos_sum_(1 - u_to_v, 0, 1)
775  + pre_sum_(1 - u_to_v, 0, 1);
776  // i --> j, j --> k, i --> k
777  triad_counts_(0, 1, 0) += mid_sum_(1 - u_to_v, 0, 0)
778  + pos_sum_(u_to_v, 1, 1)
779  + pre_sum_(1 - u_to_v, 1, 0);
780  // i --> j, i --> k, j --> k
781  triad_counts_(1, 1, 0) += mid_sum_(1 - u_to_v, 1, 0)
782  + pos_sum_(1 - u_to_v, 1, 1)
783  + pre_sum_(1 - u_to_v, 0, 0);
784  // i --> j, k --> j, k --> i
785  triad_counts_(0, 0, 1) += mid_sum_(u_to_v, 0, 1)
786  + pos_sum_(u_to_v, 0, 0)
787  + pre_sum_(u_to_v, 1, 1);
788  // i --> j, k --> i, k --> j
789  triad_counts_(1, 0, 1) += mid_sum_(u_to_v, 1, 1)
790  + pos_sum_(1 - u_to_v, 0, 0)
791  + pre_sum_(u_to_v, 0, 1);
792  // i --> j, j --> k, k --> i
793  triad_counts_(0, 1, 1) += mid_sum_(1 - u_to_v, 0, 1)
794  + pos_sum_(u_to_v, 1, 0)
795  + pre_sum_(u_to_v, 1, 0);
796  // i --> j, i --> k, k --> j
797  triad_counts_(1, 1, 1) += mid_sum_(1 - u_to_v, 1, 1)
798  + pos_sum_(1 - u_to_v, 1, 0)
799  + pre_sum_(u_to_v, 0, 0);
800  }
801 }
bool IsEdgeNode(int nbr)
void ThreeTEdgeTriadCounter::PushPos ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 738 of file temporalmotifs.cpp.

738  {
739  int nbr = event.nbr;
740  int dir = event.dir;
741  int u_or_v = event.u_or_v;
742  if (!IsEdgeNode(nbr)) {
743  for (int i = 0; i < 2; i++) {
744  pos_sum_(1 - u_or_v, i, dir) += pos_nodes_(i, 1 - u_or_v, nbr);
745  }
746  pos_nodes_(dir, u_or_v, nbr) += 1;
747  }
748 }
bool IsEdgeNode(int nbr)
void ThreeTEdgeTriadCounter::PushPre ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 726 of file temporalmotifs.cpp.

726  {
727  int nbr = event.nbr;
728  int dir = event.dir;
729  int u_or_v = event.u_or_v;
730  if (!IsEdgeNode(nbr)) {
731  for (int i = 0; i < 2; i++) {
732  pre_sum_(1 - u_or_v, i, dir) += pre_nodes_(i, 1 - u_or_v, nbr);
733  }
734  pre_nodes_(dir, u_or_v, nbr) += 1;
735  }
736 }
bool IsEdgeNode(int nbr)

Member Data Documentation

int ThreeTEdgeTriadCounter::max_nodes_
private

Definition at line 291 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::mid_sum_
private

Definition at line 294 of file temporalmotifs.h.

int ThreeTEdgeTriadCounter::node_u_
private

Definition at line 299 of file temporalmotifs.h.

int ThreeTEdgeTriadCounter::node_v_
private

Definition at line 300 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::pos_nodes_
private

Definition at line 297 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::pos_sum_
private

Definition at line 293 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::pre_nodes_
private

Definition at line 296 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::pre_sum_
private

Definition at line 292 of file temporalmotifs.h.

Counter3D ThreeTEdgeTriadCounter::triad_counts_
private

Definition at line 295 of file temporalmotifs.h.


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