SNAP Library 2.2, User Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TLocClustStat::TCutInfo Class Reference

#include <ncp.h>

List of all members.

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

Definition at line 152 of file ncp.h.

: 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.

: 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.

                                                                                                   :
      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.

                                                                             : Nodes(ClustNIdV.Len()) {
      TSnap::GetEdgesInOut(G, ClustNIdV, Edges.Val, CutSz.Val); if(TakeNIdV){CutNIdV=ClustNIdV;} }
TLocClustStat::TCutInfo::TCutInfo ( const TCutInfo CS) [inline]

Definition at line 158 of file ncp.h.

: 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.

{ 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.

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

Definition at line 160 of file ncp.h.

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

Definition at line 165 of file ncp.h.

{ 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.

{ return TMath::Sqr(2.0*Edges+CutSz)/(2.0*GEdges); }        // expected edges inside (sum of degrees on nodes inside)^2/(2*E)
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.

                                                                                                                                                             {
  if (CutNIdV.Empty()) {
    IAssert(Nodes<100 || ! CutNIdV.Empty());
    MxFrac=1; AvgFrac=1; MedianFrac=1; Pct9Frac=1; Flake=1; 
    return 1;
  }
  TMom FracDegMom;
  TIntSet InNIdSet(CutNIdV.Len());
  int NHalfIn=0;
  for (int i = 0; i < CutNIdV.Len(); i++) { 
    InNIdSet.AddKey(CutNIdV[i]); }
  for (int n = 0; n < CutNIdV.Len(); n++) {
    const TUNGraph::TNodeI NI = Graph->GetNI(CutNIdV[n]);
    int EdgesOut = 0;
    for (int i = 0; i < NI.GetDeg(); i++) {
      if (! InNIdSet.IsKey(NI.GetNbrNId(i))) { EdgesOut++; }
    }
    const double FracOut = EdgesOut/double(NI.GetDeg());
    if (FracOut <= 0.5) { NHalfIn++; }
    FracDegMom.Add(FracOut);
  }
  FracDegMom.Def();
  MxFrac = FracDegMom.GetMx();
  AvgFrac = FracDegMom.GetMean();
  MedianFrac = FracDegMom.GetMedian();
  Pct9Frac = FracDegMom.GetDecile(9);
  Flake = 1.0 - double(NHalfIn)/double(CutNIdV.Len());
  return MxFrac;
}
double TLocClustStat::TCutInfo::GetIntDens ( ) const [inline]

Definition at line 166 of file ncp.h.

{ 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.

{ return (2.0*Edges) / GetExpEdgesIn(GEdges); }                 // modularity ratio
double TLocClustStat::TCutInfo::GetModular ( const int &  GEdges) const [inline]

Definition at line 170 of file ncp.h.

{ return (2.0*Edges - GetExpEdgesIn(GEdges)) / (2.0*GEdges); } // modularity
int TLocClustStat::TCutInfo::GetNodes ( ) const [inline]

Definition at line 159 of file ncp.h.

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

Definition at line 168 of file ncp.h.

{ return GetPhi() + double(CutSz)/double(2*GEdges-GetVol()); } // normalized cut
double TLocClustStat::TCutInfo::GetPhi ( ) const [inline]

Definition at line 164 of file ncp.h.

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

Definition at line 161 of file ncp.h.

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

Definition at line 173 of file ncp.h.

{ return GetPhi() < CS.GetPhi(); }

Member Data Documentation

Definition at line 150 of file ncp.h.

Definition at line 149 of file ncp.h.

Definition at line 149 of file ncp.h.

Definition at line 149 of file ncp.h.


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