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
|
Local Spectral Clustering algorithm. More...
#include <ncp.h>
Public Member Functions | |
TLocClust (const PUNGraph &GraphPt, const double &AlphaVal) | |
int | Len () const |
Returns the support of the approximate random walk, the number of nodes with non-zero PageRank score. More... | |
int | GetRndWalkSup () const |
Returns the support of the approximate random walk, the number of nodes with non-zero PageRank score. More... | |
int | GetNId (const int &NodeN) const |
Returns the ID of the NodeN-th node in the sweep vector. More... | |
int | GetVol (const int &Nodes) const |
Returns the volume of the set of first NodeN nodes in the sweep vector. More... | |
int | GetCut (const int &Nodes) const |
Returns the size of the cut of the first Nodes nodes in the sweep vector. More... | |
double | GetPhi (const int &ValId) const |
Returns the conductance of the cut separating the first Nodes nodes in the sweep vector from the rest of the graph. More... | |
const TIntV & | GetNIdV () const |
Vector of node IDs sorted in the random walk order. More... | |
const TIntV & | GetVolV () const |
Volume (sum of the degrees) of first K-nodes in the node-id vector (GetNIdV()). More... | |
const TIntV & | GetCutV () const |
Edges cut to separate the first K-nodes in the node-id vector (GetNIdV()) from the rest of the graph. More... | |
const TFltV & | GetPhiV () const |
Conducatance of the cut separating first K-nodes in the node-id vector (GetNIdV()) from the rest of the graph. More... | |
int | BestCut () const |
Index K of the cut of the minimum conductance around the seed node. More... | |
int | BestCutNodes () const |
Number of nodes inside the 'best' (minimum conductance) cut. More... | |
int | GetCutEdges () const |
Number of edges in the 'best' (minimum conductance) cut. More... | |
int | GetCutVol () const |
Volume of the 'best' (minimum conductance) cut. More... | |
double | GetCutPhi () const |
Conductance of the 'best' (minimum conductance) cut. More... | |
int | ApproxPageRank (const int &SeedNode, const double &Eps) |
Computes Approximate PageRank from the seed node SeedNId and with tolerance Eps. More... | |
void | SupportSweep () |
After the function ApproxPageRank() has been run the SupportSweep() computes the volume, cut size, node ids, conductance vectors. More... | |
void | FindBestCut (const int &SeedNode, const int &ClustSz, const double &MinSizeFrac=0.2) |
Finds minimum conductance cut in the graph around the seed node. More... | |
void | PlotVolDistr (const TStr &OutFNm, TStr Desc=TStr()) const |
Plots the cluster volume vs. cluster size K (cluster is composed of nodes NIdV[1...K]). More... | |
void | PlotCutDistr (const TStr &OutFNm, TStr Desc=TStr()) const |
Plots the cluster cut size vs. cluster size K (cluster is composed of nodes NIdV[1...K]). More... | |
void | PlotPhiDistr (const TStr &OutFNm, TStr Desc=TStr()) const |
Plots the cluster conductance vs. cluster size K (cluster is composed of nodes NIdV[1...K]). More... | |
void | SavePajek (const TStr &OutFNm) const |
Saves the network in the Pajek format so it can be visualized. Red node represents the seed and color the cluster membership. More... | |
Static Public Member Functions | |
static void | DrawWhiskers (const PUNGraph &Graph, TStr FNmPref, const int &PlotN) |
Draws the 'whiskers' of the graph. Whiskers are small sub-graphs that are attached to the rest of the graph via a single edge. More... | |
static void | GetCutStat (const PUNGraph &Graph, const TIntV &NIdV, int &Vol, int &Cut, double &Phi, int GraphEdges=-1) |
For a given Graph and a set of nodes NIdV the function returns the Volume, CutSize and the Conductance of the cut. More... | |
static void | GetCutStat (const PUNGraph &Graph, const TIntSet &NIdSet, int &Vol, int &Cut, double &Phi, int GraphEdges=-1) |
For a given Graph and a set of nodes NIdV the function returns the Volume, CutSize and the Conductance of the cut. More... | |
static void | PlotNCP (const PUNGraph &Graph, const TStr &FNm, const TStr Desc="", const bool &BagOfWhiskers=true, const bool &RewireNet=false, const int &KMin=10, const int &KMax=Mega(100), const int &Coverage=10, const bool &SaveTxtStat=false, const bool &PlotBoltzman=false) |
Static Public Attributes | |
static bool | Verbose = true |
Private Attributes | |
PUNGraph | Graph |
int | Nodes |
int | Edges2 |
TIntFltH | ProbH |
TIntFltH | ResH |
TIntQ | NodeQ |
double | Alpha |
int | SeedNId |
TIntV | NIdV |
TIntV | VolV |
TIntV | CutV |
TFltV | PhiV |
int | BestCutIdx |
Friends | |
class | TLocClustStat |
Local Spectral Clustering algorithm.
The code implements the PageRank Nibble local clustering algorithm of Andersen, Chung and Lang. Given a single starting seed node, the algorithm will then find the clusters around that node. This is achieved by the algorithm finding the approximate personalized PageRank score of every node with respect to the Seed node. Nodes are then ordered by the PageRank score and the idea is then that by 'sweeping' the vector of PageRank scores one can find communities around the chosen seed node. The idea is to try out K = 1...N/2 and then for a set of {node_1 ... node_K} test the value of the conductance (Phi). If the conductance at certain value of K achieves a local minima, then we found a good cut in the graph. This method is also used for computing the Network Community Profile plots. See: Local Graph Partitioning using PageRank Vectors by R. Andersen, F. Chung and K. Lang URL: http://www.math.ucsd.edu/~fan/wp/localpartition.pdf
|
inline |
int TLocClust::ApproxPageRank | ( | const int & | SeedNode, |
const double & | Eps | ||
) |
Computes Approximate PageRank from the seed node SeedNId and with tolerance Eps.
The algorithm basically sets the PageRank scores of nodes with score <Eps to zero. So the lower the value of Eps the longer the algorithm will run.
Definition at line 9 of file ncp.cpp.
|
inline |
|
inline |
|
static |
Draws the 'whiskers' of the graph. Whiskers are small sub-graphs that are attached to the rest of the graph via a single edge.
Definition at line 172 of file ncp.cpp.
void TLocClust::FindBestCut | ( | const int & | SeedNode, |
const int & | ClustSz, | ||
const double & | MinSizeFrac = 0.2 |
||
) |
Finds minimum conductance cut in the graph around the seed node.
Function first computes the ApproxPageRank(), initializes the SupportSweep() and then find the minimum conductance cluster. Parameter ClustSz controls the expected cluster size and is used to determine the tolerance (Eps) of the approximate PageRank calculation.
Definition at line 81 of file ncp.cpp.
|
inline |
|
inline |
Number of edges in the 'best' (minimum conductance) cut.
|
inline |
Conductance of the 'best' (minimum conductance) cut.
|
static |
For a given Graph and a set of nodes NIdV the function returns the Volume, CutSize and the Conductance of the cut.
Definition at line 192 of file ncp.cpp.
|
static |
For a given Graph and a set of nodes NIdV the function returns the Volume, CutSize and the Conductance of the cut.
Definition at line 198 of file ncp.cpp.
|
inline |
|
inline |
Volume of the 'best' (minimum conductance) cut.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the support of the approximate random walk, the number of nodes with non-zero PageRank score.
|
inline |
|
inline |
|
inline |
Plots the cluster cut size vs. cluster size K (cluster is composed of nodes NIdV[1...K]).
Definition at line 113 of file ncp.cpp.
|
static |
Plots the Network Community Profile (NCP) of a given graph Graph. The NCP plot of a network captures the global community structure of the network. The NCP plot of a network captures the global community structure of the network. Refer to 'Community Structure in Large Networks: Natural Cluster Sizes and the Absence of Large Well-Defined Clusters by J. Leskovec, K. Lang, A. Dasgupta, M. Mahoney. Internet Mathematics 6(1) 29–123, 2009' for the explanation of how to read these plots. URL: http://arxiv.org/abs/0810.1355
Definition at line 219 of file ncp.cpp.
Plots the cluster conductance vs. cluster size K (cluster is composed of nodes NIdV[1...K]).
Definition at line 126 of file ncp.cpp.
Plots the cluster volume vs. cluster size K (cluster is composed of nodes NIdV[1...K]).
Definition at line 100 of file ncp.cpp.
void TLocClust::SavePajek | ( | const TStr & | OutFNm | ) | const |
Saves the network in the Pajek format so it can be visualized. Red node represents the seed and color the cluster membership.
Definition at line 139 of file ncp.cpp.
void TLocClust::SupportSweep | ( | ) |
After the function ApproxPageRank() has been run the SupportSweep() computes the volume, cut size, node ids, conductance vectors.
Definition at line 52 of file ncp.cpp.
|
friend |