SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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>

Inheritance diagram for ThreeTEdgeTriadCounter:
Collaboration diagram for ThreeTEdgeTriadCounter:

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.

References triad_counts_.

Referenced by TempMotifCounter::Count3TEdgeTriads().

279 { return triad_counts_(dir1, dir2, dir3); }

Here is the caller graph for this function:

void ThreeTEdgeTriadCounter::InitializeCounters ( )
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 691 of file temporalmotifs.cpp.

References max_nodes_, mid_sum_, pos_nodes_, pos_sum_, pre_nodes_, pre_sum_, and triad_counts_.

691  {
694  pre_sum_ = Counter3D(2, 2, 2);
695  pos_sum_ = Counter3D(2, 2, 2);
696  mid_sum_ = Counter3D(2, 2, 2);
697  triad_counts_ = Counter3D(2, 2, 2);
698 }
bool ThreeTEdgeTriadCounter::IsEdgeNode ( int  nbr)
inlineprotected

Definition at line 288 of file temporalmotifs.h.

References node_u_, and node_v_.

Referenced by PopPos(), PopPre(), ProcessCurrent(), PushPos(), and PushPre().

288 { return nbr == node_u_ || nbr == node_v_; }

Here is the caller graph for this function:

void ThreeTEdgeTriadCounter::PopPos ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 712 of file temporalmotifs.cpp.

References IsEdgeNode(), pos_nodes_, and pos_sum_.

712  {
713  int nbr = event.nbr;
714  int dir = event.dir;
715  int u_or_v = event.u_or_v;
716  if (!IsEdgeNode(nbr)) {
717  pos_nodes_(dir, u_or_v, nbr) -= 1;
718  for (int i = 0; i < 2; i++) {
719  pos_sum_(u_or_v, dir, i) -= pos_nodes_(i, 1 - u_or_v, nbr);
720  }
721  }
722 }
bool IsEdgeNode(int nbr)

Here is the call graph for this function:

void ThreeTEdgeTriadCounter::PopPre ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 700 of file temporalmotifs.cpp.

References IsEdgeNode(), pre_nodes_, and pre_sum_.

700  {
701  int nbr = event.nbr;
702  int dir = event.dir;
703  int u_or_v = event.u_or_v;
704  if (!IsEdgeNode(nbr)) {
705  pre_nodes_(dir, u_or_v, nbr) -= 1;
706  for (int i = 0; i < 2; i++) {
707  pre_sum_(u_or_v, dir, i) -= pre_nodes_(i, 1 - u_or_v, nbr);
708  }
709  }
710 }
bool IsEdgeNode(int nbr)

Here is the call graph for this function:

void ThreeTEdgeTriadCounter::ProcessCurrent ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 748 of file temporalmotifs.cpp.

References IsEdgeNode(), mid_sum_, node_u_, node_v_, pos_nodes_, pos_sum_, pre_nodes_, pre_sum_, and triad_counts_.

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

Here is the call graph for this function:

void ThreeTEdgeTriadCounter::PushPos ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 736 of file temporalmotifs.cpp.

References IsEdgeNode(), pos_nodes_, and pos_sum_.

736  {
737  int nbr = event.nbr;
738  int dir = event.dir;
739  int u_or_v = event.u_or_v;
740  if (!IsEdgeNode(nbr)) {
741  for (int i = 0; i < 2; i++) {
742  pos_sum_(1 - u_or_v, i, dir) += pos_nodes_(i, 1 - u_or_v, nbr);
743  }
744  pos_nodes_(dir, u_or_v, nbr) += 1;
745  }
746 }
bool IsEdgeNode(int nbr)

Here is the call graph for this function:

void ThreeTEdgeTriadCounter::PushPre ( const TriadEdgeData event)
protectedvirtual

Implements StarTriad3TEdgeCounter< TriadEdgeData >.

Definition at line 724 of file temporalmotifs.cpp.

References IsEdgeNode(), pre_nodes_, and pre_sum_.

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

Here is the call graph for this function:

Member Data Documentation

int ThreeTEdgeTriadCounter::max_nodes_
private

Definition at line 291 of file temporalmotifs.h.

Referenced by InitializeCounters().

Counter3D ThreeTEdgeTriadCounter::mid_sum_
private

Definition at line 294 of file temporalmotifs.h.

Referenced by InitializeCounters(), and ProcessCurrent().

int ThreeTEdgeTriadCounter::node_u_
private

Definition at line 299 of file temporalmotifs.h.

Referenced by IsEdgeNode(), and ProcessCurrent().

int ThreeTEdgeTriadCounter::node_v_
private

Definition at line 300 of file temporalmotifs.h.

Referenced by IsEdgeNode(), and ProcessCurrent().

Counter3D ThreeTEdgeTriadCounter::pos_nodes_
private

Definition at line 297 of file temporalmotifs.h.

Referenced by InitializeCounters(), PopPos(), ProcessCurrent(), and PushPos().

Counter3D ThreeTEdgeTriadCounter::pos_sum_
private

Definition at line 293 of file temporalmotifs.h.

Referenced by InitializeCounters(), PopPos(), ProcessCurrent(), and PushPos().

Counter3D ThreeTEdgeTriadCounter::pre_nodes_
private

Definition at line 296 of file temporalmotifs.h.

Referenced by InitializeCounters(), PopPre(), ProcessCurrent(), and PushPre().

Counter3D ThreeTEdgeTriadCounter::pre_sum_
private

Definition at line 292 of file temporalmotifs.h.

Referenced by InitializeCounters(), PopPre(), ProcessCurrent(), and PushPre().

Counter3D ThreeTEdgeTriadCounter::triad_counts_
private

Definition at line 295 of file temporalmotifs.h.

Referenced by Counts(), InitializeCounters(), and ProcessCurrent().


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