SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TLocClustStat::TCutInfo Class Reference

#include <ncp.h>

Public Member Functions

 TCutInfo ()
 
 TCutInfo (const int &ClustNodes, const int &EdgesInside, const int &CutSize)
 
 TCutInfo (const int &ClustNodes, const int &EdgesInside, const int &CutSize, const TIntV &NIdV)
 
 TCutInfo (const PUNGraph &G, const TIntV &ClustNIdV, bool TakeNIdV=false)
 
 TCutInfo (const TCutInfo &CS)
 
int GetNodes () const
 
int GetEdges () const
 
int GetVol () const
 
int GetCutSz () const
 
double GetPhi () const
 
double GetExpansion () const
 
double GetIntDens () const
 
double GetCutRatio (const int &GNodes) const
 
double GetNormCut (const int &GEdges) const
 
double GetFracDegOut (const PUNGraph &Graph, double &MxFrac, double &AvgFrac, double &MedianFrac, double &Pct9Frac, double &Flake) const
 
double GetModular (const int &GEdges) const
 
double GetModRat (const int &GEdges) const
 
double GetExpEdgesIn (const int &GEdges) const
 
bool operator< (const TCutInfo &CS) const
 

Public Attributes

TInt Nodes
 
TInt Edges
 
TInt CutSz
 
TIntV CutNIdV
 

Detailed Description

Definition at line 147 of file ncp.h.

Constructor & Destructor Documentation

TLocClustStat::TCutInfo::TCutInfo ( )
inline

Definition at line 152 of file ncp.h.

152 : Nodes(0), Edges(0), CutSz(0), CutNIdV() { }
TLocClustStat::TCutInfo::TCutInfo ( const int &  ClustNodes,
const int &  EdgesInside,
const int &  CutSize 
)
inline

Definition at line 153 of file ncp.h.

153 : Nodes(ClustNodes), Edges(EdgesInside), CutSz(CutSize) { }
TLocClustStat::TCutInfo::TCutInfo ( const int &  ClustNodes,
const int &  EdgesInside,
const int &  CutSize,
const TIntV NIdV 
)
inline

Definition at line 154 of file ncp.h.

154  :
155  Nodes(ClustNodes), Edges(EdgesInside), CutSz(CutSize), CutNIdV(NIdV) { }
TLocClustStat::TCutInfo::TCutInfo ( const PUNGraph G,
const TIntV ClustNIdV,
bool  TakeNIdV = false 
)
inline

Definition at line 156 of file ncp.h.

156  : Nodes(ClustNIdV.Len()) {
157  TSnap::GetEdgesInOut(G, ClustNIdV, Edges.Val, CutSz.Val); if(TakeNIdV){CutNIdV=ClustNIdV;} }
int Val
Definition: dt.h:1139
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void GetEdgesInOut(const PGraph &Graph, const TIntV &NIdV, int &EdgesInX, int &EdgesOutX)
Definition: cmty.h:76
TLocClustStat::TCutInfo::TCutInfo ( const TCutInfo CS)
inline

Definition at line 158 of file ncp.h.

158 : Nodes(CS.Nodes), Edges(CS.Edges), CutSz(CS.CutSz), CutNIdV(CS.CutNIdV) { }

Member Function Documentation

double TLocClustStat::TCutInfo::GetCutRatio ( const int &  GNodes) const
inline

Definition at line 167 of file ncp.h.

167 { return double(CutSz)/double(Nodes*(GNodes-Nodes)); } // cut ratio (external density)
int TLocClustStat::TCutInfo::GetCutSz ( ) const
inline

Definition at line 162 of file ncp.h.

162 { return CutSz; }
int TLocClustStat::TCutInfo::GetEdges ( ) const
inline

Definition at line 160 of file ncp.h.

160 { return Edges; }
double TLocClustStat::TCutInfo::GetExpansion ( ) const
inline

Definition at line 165 of file ncp.h.

165 { return Nodes<2 ? 1.0 : double(CutSz)/double(Nodes); } // expansion
double TLocClustStat::TCutInfo::GetExpEdgesIn ( const int &  GEdges) const
inline

Definition at line 172 of file ncp.h.

172 { return TMath::Sqr(2.0*Edges+CutSz)/(2.0*GEdges); } // expected edges inside (sum of degrees on nodes inside)^2/(2*E)
static double Sqr(const double &x)
Definition: xmath.h:12
double TLocClustStat::TCutInfo::GetFracDegOut ( const PUNGraph Graph,
double &  MxFrac,
double &  AvgFrac,
double &  MedianFrac,
double &  Pct9Frac,
double &  Flake 
) const

Definition at line 245 of file ncp.cpp.

245  {
246  if (CutNIdV.Empty()) {
247  IAssert(Nodes<100 || ! CutNIdV.Empty());
248  MxFrac=1; AvgFrac=1; MedianFrac=1; Pct9Frac=1; Flake=1;
249  return 1;
250  }
251  TMom FracDegMom;
252  TIntSet InNIdSet(CutNIdV.Len());
253  int NHalfIn=0;
254  for (int i = 0; i < CutNIdV.Len(); i++) {
255  InNIdSet.AddKey(CutNIdV[i]); }
256  for (int n = 0; n < CutNIdV.Len(); n++) {
257  const TUNGraph::TNodeI NI = Graph->GetNI(CutNIdV[n]);
258  int EdgesOut = 0;
259  for (int i = 0; i < NI.GetDeg(); i++) {
260  if (! InNIdSet.IsKey(NI.GetNbrNId(i))) { EdgesOut++; }
261  }
262  const double FracOut = EdgesOut/double(NI.GetDeg());
263  if (FracOut <= 0.5) { NHalfIn++; }
264  FracDegMom.Add(FracOut);
265  }
266  FracDegMom.Def();
267  MxFrac = FracDegMom.GetMx();
268  AvgFrac = FracDegMom.GetMean();
269  MedianFrac = FracDegMom.GetMedian();
270  Pct9Frac = FracDegMom.GetDecile(9);
271  Flake = 1.0 - double(NHalfIn)/double(CutNIdV.Len());
272  return MxFrac;
273 }
#define IAssert(Cond)
Definition: bd.h:262
double GetMedian() const
Definition: xmath.h:244
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Node iterator. Only forward iteration (operator++) is supported.
Definition: graph.h:68
Definition: xmath.h:129
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
int GetDeg() const
Returns degree of the current node.
Definition: graph.h:90
double GetMx() const
Definition: xmath.h:238
void Add(const TFlt &Val, const TFlt &Wgt=1)
Definition: xmath.h:217
int AddKey(const TKey &Key)
Definition: shash.h:1254
double GetMean() const
Definition: xmath.h:240
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
Definition: graph.h:111
double GetDecile(const int &DecileN) const
Definition: xmath.h:248
void Def()
Definition: xmath.cpp:339
double TLocClustStat::TCutInfo::GetIntDens ( ) const
inline

Definition at line 166 of file ncp.h.

166 { return 1.0 - ((Nodes<2) ? 0 : 2.0*double(Edges)/double(Nodes*(Nodes-1))); } // internal density
double TLocClustStat::TCutInfo::GetModRat ( const int &  GEdges) const
inline

Definition at line 171 of file ncp.h.

171 { return (2.0*Edges) / GetExpEdgesIn(GEdges); } // modularity ratio
double GetExpEdgesIn(const int &GEdges) const
Definition: ncp.h:172
double TLocClustStat::TCutInfo::GetModular ( const int &  GEdges) const
inline

Definition at line 170 of file ncp.h.

170 { return (2.0*Edges - GetExpEdgesIn(GEdges)) / (2.0*GEdges); } // modularity
double GetExpEdgesIn(const int &GEdges) const
Definition: ncp.h:172
int TLocClustStat::TCutInfo::GetNodes ( ) const
inline

Definition at line 159 of file ncp.h.

159 { return Nodes; }
double TLocClustStat::TCutInfo::GetNormCut ( const int &  GEdges) const
inline

Definition at line 168 of file ncp.h.

168 { return GetPhi() + double(CutSz)/double(2*GEdges-GetVol()); } // normalized cut
double GetPhi() const
Definition: ncp.h:164
int GetVol() const
Definition: ncp.h:161
double TLocClustStat::TCutInfo::GetPhi ( ) const
inline

Definition at line 164 of file ncp.h.

164 { return double(CutSz)/double(2*Edges+CutSz); } // conductance
int TLocClustStat::TCutInfo::GetVol ( ) const
inline

Definition at line 161 of file ncp.h.

161 { return 2*Edges+CutSz; }
bool TLocClustStat::TCutInfo::operator< ( const TCutInfo CS) const
inline

Definition at line 173 of file ncp.h.

173 { return GetPhi() < CS.GetPhi(); }
double GetPhi() const
Definition: ncp.h:164

Member Data Documentation

TIntV TLocClustStat::TCutInfo::CutNIdV

Definition at line 150 of file ncp.h.

TInt TLocClustStat::TCutInfo::CutSz

Definition at line 149 of file ncp.h.

TInt TLocClustStat::TCutInfo::Edges

Definition at line 149 of file ncp.h.

TInt TLocClustStat::TCutInfo::Nodes

Definition at line 149 of file ncp.h.


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