SNAP Library 3.0, Developer Reference  2016-07-20 17:56:49
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
TLocClustStat::TCutInfo Class Reference

#include <ncp.h>

Collaboration diagram for TLocClustStat::TCutInfo:

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.

References CutNIdV, CutSz, Edges, TSnap::GetEdgesInOut(), and TInt::Val.

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

Here is the call graph for this function:

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.

References CutSz, and Nodes.

Referenced by TLocClustStat::SaveTxtInfo().

167 { return double(CutSz)/double(Nodes*(GNodes-Nodes)); } // cut ratio (external density)

Here is the caller graph for this function:

int TLocClustStat::TCutInfo::GetCutSz ( ) const
inline

Definition at line 162 of file ncp.h.

References CutSz.

Referenced by TLocClustStat::AddToBestCutH(), TLocClustStat::FindBestCut(), and TLocClustStat::PlotPhiInOut().

162 { return CutSz; }

Here is the caller graph for this function:

int TLocClustStat::TCutInfo::GetEdges ( ) const
inline

Definition at line 160 of file ncp.h.

References Edges.

Referenced by TLocClustStat::AddToBestCutH(), and TLocClustStat::PlotPhiInOut().

160 { return Edges; }

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetExpansion ( ) const
inline

Definition at line 165 of file ncp.h.

References CutSz, and Nodes.

Referenced by TLocClustStat::SaveTxtInfo().

165 { return Nodes<2 ? 1.0 : double(CutSz)/double(Nodes); } // expansion

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetExpEdgesIn ( const int &  GEdges) const
inline

Definition at line 172 of file ncp.h.

References CutSz, Edges, and TMath::Sqr().

Referenced by GetModRat(), GetModular(), and TLocClustStat::SaveTxtInfo().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.

References TMom::Add(), THashSet< TKey, THashFunc >::AddKey(), CutNIdV, TMom::Def(), TVec< TVal, TSizeTy >::Empty(), TMom::GetDecile(), TUNGraph::TNodeI::GetDeg(), TMom::GetMean(), TMom::GetMedian(), TMom::GetMx(), TUNGraph::TNodeI::GetNbrNId(), TUNGraph::GetNI(), IAssert, TVec< TVal, TSizeTy >::Len(), and Nodes.

Referenced by TLocClustStat::SaveTxtInfo().

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:547
Node iterator. Only forward iteration (operator++) is supported.
Definition: graph.h:64
Definition: xmath.h:129
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:542
int GetDeg() const
Returns degree of the current node.
Definition: graph.h:86
double GetMx() const
Definition: xmath.h:238
void Add(const TFlt &Val, const TFlt &Wgt=1)
Definition: xmath.h:217
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: graph.h:213
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:107
double GetDecile(const int &DecileN) const
Definition: xmath.h:248
void Def()
Definition: xmath.cpp:339

Here is the call graph for this function:

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetIntDens ( ) const
inline

Definition at line 166 of file ncp.h.

References Edges, and Nodes.

Referenced by TLocClustStat::SaveTxtInfo().

166 { return 1.0 - ((Nodes<2) ? 0 : 2.0*double(Edges)/double(Nodes*(Nodes-1))); } // internal density

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetModRat ( const int &  GEdges) const
inline

Definition at line 171 of file ncp.h.

References Edges, and GetExpEdgesIn().

Referenced by TLocClustStat::SaveTxtInfo().

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

Here is the call graph for this function:

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetModular ( const int &  GEdges) const
inline

Definition at line 170 of file ncp.h.

References Edges, and GetExpEdgesIn().

Referenced by TLocClustStat::AddToBestCutH(), and TLocClustStat::SaveTxtInfo().

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

Here is the call graph for this function:

Here is the caller graph for this function:

int TLocClustStat::TCutInfo::GetNodes ( ) const
inline

Definition at line 159 of file ncp.h.

References Nodes.

Referenced by TLocClustStat::AddToBestCutH(), TLocClustStat::FindBestCut(), and TLocClustStat::PlotPhiInOut().

159 { return Nodes; }

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetNormCut ( const int &  GEdges) const
inline

Definition at line 168 of file ncp.h.

References CutSz, GetPhi(), and GetVol().

Referenced by TLocClustStat::SaveTxtInfo().

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

Here is the call graph for this function:

Here is the caller graph for this function:

double TLocClustStat::TCutInfo::GetPhi ( ) const
inline

Definition at line 164 of file ncp.h.

References CutSz, and Edges.

Referenced by TLocClustStat::AddToBestCutH(), TLocClustStat::FindBestCut(), GetNormCut(), operator<(), TLocClustStat::PlotPhiInOut(), and TLocClustStat::SaveTxtInfo().

164 { return double(CutSz)/double(2*Edges+CutSz); } // conductance

Here is the caller graph for this function:

int TLocClustStat::TCutInfo::GetVol ( ) const
inline

Definition at line 161 of file ncp.h.

References CutSz, and Edges.

Referenced by TLocClustStat::FindBestCut(), GetNormCut(), and TLocClustStat::PlotPhiInOut().

161 { return 2*Edges+CutSz; }

Here is the caller graph for this function:

bool TLocClustStat::TCutInfo::operator< ( const TCutInfo CS) const
inline

Definition at line 173 of file ncp.h.

References GetPhi().

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

Here is the call graph for this function:

Member Data Documentation

TIntV TLocClustStat::TCutInfo::CutNIdV
TInt TLocClustStat::TCutInfo::CutSz
TInt TLocClustStat::TCutInfo::Edges
TInt TLocClustStat::TCutInfo::Nodes

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