SNAP Library 2.4, User Reference
2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Fitting the Affilialiton Graph Model (AGM). More...
#include <agmfit.h>
Public Member Functions | |
TAGMFit () | |
~TAGMFit () | |
TAGMFit (const PUNGraph &GraphPt, const TVec< TIntV > &CmtyVVPt, const int RndSeed=0) | |
COMMENT. Use to describribe parameters. More... | |
TAGMFit (const PUNGraph &GraphPt, const int InitComs, const int RndSeed=0) | |
COMMENT. Use to describribe parameters. More... | |
TAGMFit (const PUNGraph &GraphPt, const TVec< TIntV > &CmtyVVPt, const TRnd &RndPt) | |
COMMENT. Use to describribe parameters. More... | |
void | Save (TSOut &SOut) |
void | Load (TSIn &SIn, const int &RndSeed=0) |
void | RandomInitCmtyVV (const int InitComs, const double ComSzAlpha=1.3, const double MemAlpha=1.8, const int MinComSz=8, const int MaxComSz=200, const int MinMem=1, const int MaxMem=10) |
Randomly initialize bipartite community affiliation graph. More... | |
void | AddBaseCmty () |
Add Epsilon community (base community which includes all nodes) into community affiliation graph. This means that we will later fit the value of epsilon. More... | |
double | Likelihood () |
COMMENT. More... | |
double | Likelihood (const TFltV &NewLambdaV) |
double | Likelihood (const TFltV &NewLambdaV, double &LEdges, double &LNoEdges) |
void | SetRegCoef (const double Val) |
void | GetEdgeJointCom () |
For each (u, v) in edges, precompute C_uv (the set of communities nodes u and v share). More... | |
void | NeighborComInit (const int InitComs) |
Initialize node community memberships using best neighborhood communities (see D. Gleich et al. KDD'12). More... | |
void | GradLogLForLambda (TFltV &GradV) |
int | MLEGradAscentGivenCAG (const double &Thres=0.001, const int &MaxIter=10000, const TStr PlotNm=TStr()) |
Gradient descent for p_c while keeping the community affiliation graph (CAG) fixed. More... | |
void | SetDefaultPNoCom () |
Set Epsilon (the probability that two nodes sharing no communities connect) to the default value. More... | |
void | SetPNoCom (const double &Epsilon) |
Set Epsilon (the probability that two nodes sharing no communities connect) to the default value. More... | |
double | GetPNoCom () |
double | CalcPNoComByCmtyVV (const int &SamplePairs=-1) |
Compute the empirical edge probability between a pair of nodes who share no community (epsilon), based on current community affiliations. More... | |
double | SelectLambdaSum (const TIntSet &ComK) |
Compute sum of lambda_c (which is log (1 - p_c )) over C_uv (ComK ). The function is used to compute edge probability P_uv . More... | |
double | SelectLambdaSum (const TFltV &NewLambdaV, const TIntSet &ComK) |
COMMENT. More... | |
void | RandomInit (const int &MaxK) |
COMMENT. More... | |
void | RunMCMC (const int &MaxIter, const int &EvalLambdaIter, const TStr &PlotFPrx=TStr()) |
Main procedure for fitting the AGM to a given graph using MCMC. More... | |
void | SampleTransition (int &NID, int &JoinCID, int &LeaveCID, double &DeltaL) |
Sample MMCM transitions: Choose among (join, leave, switch ), and then sample (NID, CID ). More... | |
void | InitNodeData () |
COMMENT. More... | |
void | LeaveCom (const int &NID, const int &CID) |
After MCMC, NID leaves community CID . More... | |
void | JoinCom (const int &NID, const int &JoinCID) |
int | RemoveEmptyCom () |
Remove all communities with no members. More... | |
double | SeekLeave (const int &UID, const int &CID) |
Compute the change in likelihood (Delta) if node UID leaves community CID . More... | |
double | SeekJoin (const int &UID, const int &CID) |
Compute the change in likelihood (Delta) if node UID joins community CID . More... | |
double | SeekSwitch (const int &UID, const int &CurCID, const int &NewCID) |
double | GetStepSizeByLineSearchForLambda (const TFltV &DeltaV, const TFltV &GradV, const double &Alpha, const double &Beta) |
Step size search for updating P_c (which is parametarized by regularization parameter lambda). More... | |
void | SetLambdaV (const TFltV &LambdaPt) |
COMMENT. More... | |
void | GetLambdaV (TFltV &OutV) |
COMMENT. More... | |
void | GetQV (TFltV &OutV) |
Returns QV , a vector of (1 - p_c ) for each community c . More... | |
void | GetCmtyVV (TVec< TIntV > &CmtyVV, const double QMax=2.0) |
Get communities whose p_c is higher than 1 - QMax . More... | |
void | GetCmtyVV (TVec< TIntV > &CmtyVV, TFltV &QV, const double QMax=2.0) |
COMMENT. More... | |
void | SetCmtyVV (const TVec< TIntV > &CmtyVV) |
COMMENT. More... | |
void | PrintSummary () |
COMMENT. More... | |
Private Attributes | |
PUNGraph | G |
Graph to fit. More... | |
TVec< TIntSet > | CIDNSetV |
Community ID -> Member Node ID Sets. More... | |
THash< TIntPr, TIntSet > | EdgeComVH |
Edge -> Shared Community ID Set. More... | |
THash< TInt, TIntSet > | NIDComVH |
Node ID -> Communitie IDs the node belongs to. More... | |
TIntV | ComEdgesV |
The number of edges in each community. More... | |
TFlt | PNoCom |
Probability of edge when two nodes share no community (epsilon in the paper). More... | |
TFltV | LambdaV |
Parametrization of P_c (edge probability in community c), P_c = 1 - exp(-lambda). More... | |
TRnd | Rnd |
THash< TIntPr, TFlt > | NIDCIDPrH |
<Node ID, Community ID> pairs (for sampling MCMC moves). More... | |
THash< TIntPr, TInt > | NIDCIDPrS |
<Node ID, Community ID> pairs (for sampling MCMC moves). More... | |
TFlt | MinLambda |
Minimum value of regularization parameter lambda (default = 1e-5). More... | |
TFlt | MaxLambda |
Maximum value of regularization parameter lambda (default = 10). More... | |
TFlt | RegCoef |
Regularization parameter when we fit for P_c (for finding # communities). More... | |
TInt | BaseCID |
ID of the Epsilon-community (in case we fit P_c of the epsilon community). We do not fit for the Epsilon-community in general. More... | |
|
inline |
COMMENT. Use to describribe parameters.
Definition at line 29 of file agmfit.h.
|
inline |
COMMENT. Use to describribe parameters.
Definition at line 31 of file agmfit.h.
|
inline |
COMMENT. Use to describribe parameters.
Definition at line 33 of file agmfit.h.
void TAGMFit::AddBaseCmty | ( | ) |
Add Epsilon community (base community which includes all nodes) into community affiliation graph. This means that we will later fit the value of epsilon.
Definition at line 251 of file agmfit.cpp.
double TAGMFit::CalcPNoComByCmtyVV | ( | const int & | SamplePairs = -1 | ) |
Compute the empirical edge probability between a pair of nodes who share no community (epsilon), based on current community affiliations.
Definition at line 632 of file agmfit.cpp.
Get communities whose p_c is higher than 1 - QMax
.
Definition at line 554 of file agmfit.cpp.
COMMENT.
Definition at line 559 of file agmfit.cpp.
void TAGMFit::GetEdgeJointCom | ( | ) |
For each (u, v)
in edges, precompute C_uv
(the set of communities nodes u and v share).
Definition at line 50 of file agmfit.cpp.
|
inline |
COMMENT.
Definition at line 94 of file agmfit.h.
|
inline |
Definition at line 58 of file agmfit.h.
void TAGMFit::GetQV | ( | TFltV & | OutV | ) |
Returns QV
, a vector of (1 - p_c
) for each community c
.
Definition at line 451 of file agmfit.cpp.
double TAGMFit::GetStepSizeByLineSearchForLambda | ( | const TFltV & | DeltaV, |
const TFltV & | GradV, | ||
const double & | Alpha, | ||
const double & | Beta | ||
) |
Step size search for updating P_c (which is parametarized by regularization parameter lambda).
Definition at line 109 of file agmfit.cpp.
void TAGMFit::GradLogLForLambda | ( | TFltV & | GradV | ) |
Definition at line 595 of file agmfit.cpp.
void TAGMFit::InitNodeData | ( | ) |
COMMENT.
Definition at line 264 of file agmfit.cpp.
void TAGMFit::JoinCom | ( | const int & | NID, |
const int & | JoinCID | ||
) |
Definition at line 309 of file agmfit.cpp.
void TAGMFit::LeaveCom | ( | const int & | NID, |
const int & | CID | ||
) |
After MCMC, NID
leaves community CID
.
Definition at line 293 of file agmfit.cpp.
double TAGMFit::Likelihood | ( | ) |
COMMENT.
Definition at line 104 of file agmfit.cpp.
|
inline |
double TAGMFit::Likelihood | ( | const TFltV & | NewLambdaV, |
double & | LEdges, | ||
double & | LNoEdges | ||
) |
Definition at line 76 of file agmfit.cpp.
void TAGMFit::Load | ( | TSIn & | SIn, |
const int & | RndSeed = 0 |
||
) |
Definition at line 24 of file agmfit.cpp.
int TAGMFit::MLEGradAscentGivenCAG | ( | const double & | Thres = 0.001 , |
const int & | MaxIter = 10000 , |
||
const TStr | PlotNm = TStr() |
||
) |
Gradient descent for p_c
while keeping the community affiliation graph (CAG) fixed.
Definition at line 130 of file agmfit.cpp.
void TAGMFit::NeighborComInit | ( | const int | InitComs | ) |
Initialize node community memberships using best neighborhood communities (see D. Gleich et al. KDD'12).
Definition at line 186 of file agmfit.cpp.
void TAGMFit::PrintSummary | ( | ) |
COMMENT.
Definition at line 659 of file agmfit.cpp.
void TAGMFit::RandomInit | ( | const int & | MaxK | ) |
COMMENT.
Definition at line 169 of file agmfit.cpp.
void TAGMFit::RandomInitCmtyVV | ( | const int | InitComs, |
const double | ComSzAlpha = 1.3 , |
||
const double | MemAlpha = 1.8 , |
||
const int | MinComSz = 8 , |
||
const int | MaxComSz = 200 , |
||
const int | MinMem = 1 , |
||
const int | MaxMem = 10 |
||
) |
Randomly initialize bipartite community affiliation graph.
Definition at line 42 of file agmfit.cpp.
int TAGMFit::RemoveEmptyCom | ( | ) |
Remove all communities with no members.
Definition at line 459 of file agmfit.cpp.
void TAGMFit::RunMCMC | ( | const int & | MaxIter, |
const int & | EvalLambdaIter, | ||
const TStr & | PlotFPrx = TStr() |
||
) |
Main procedure for fitting the AGM to a given graph using MCMC.
MCMC fitting.
Definition at line 366 of file agmfit.cpp.
void TAGMFit::SampleTransition | ( | int & | NID, |
int & | JoinCID, | ||
int & | LeaveCID, | ||
double & | DeltaL | ||
) |
Sample MMCM transitions: Choose among (join, leave, switch
), and then sample (NID, CID
).
Definition at line 325 of file agmfit.cpp.
void TAGMFit::Save | ( | TSOut & | SOut | ) |
Definition at line 8 of file agmfit.cpp.
double TAGMFit::SeekJoin | ( | const int & | UID, |
const int & | CID | ||
) |
Compute the change in likelihood (Delta) if node UID
joins community CID
.
Definition at line 502 of file agmfit.cpp.
double TAGMFit::SeekLeave | ( | const int & | UID, |
const int & | CID | ||
) |
Compute the change in likelihood (Delta) if node UID
leaves community CID
.
Definition at line 475 of file agmfit.cpp.
double TAGMFit::SeekSwitch | ( | const int & | UID, |
const int & | CurCID, | ||
const int & | NewCID | ||
) |
Definition at line 525 of file agmfit.cpp.
double TAGMFit::SelectLambdaSum | ( | const TIntSet & | ComK | ) |
Compute sum of lambda_c
(which is log (1 - p_c
)) over C_uv
(ComK
). The function is used to compute edge probability P_uv
.
Definition at line 618 of file agmfit.cpp.
COMMENT.
Definition at line 584 of file agmfit.cpp.
void TAGMFit::SetDefaultPNoCom | ( | ) |
Set Epsilon (the probability that two nodes sharing no communities connect) to the default value.
Definition at line 72 of file agmfit.cpp.
|
inline |
COMMENT.
Definition at line 92 of file agmfit.h.
|
inline |
Set Epsilon (the probability that two nodes sharing no communities connect) to the default value.
Definition at line 57 of file agmfit.h.
|
inline |
Definition at line 45 of file agmfit.h.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |