1 #ifndef snap_network_community_profile_h
2 #define snap_network_community_profile_h
47 int GetNId(
const int& NodeN)
const {
return NIdV[NodeN]; }
59 double GetPhi(
const int& ValId)
const {
return PhiV[ValId]; }
93 void FindBestCut(
const int& SeedNode,
const int& ClustSz,
const double& MinSizeFrac=0.2);
117 static void PlotNCP(
const PUNGraph&
Graph,
const TStr& FNm,
const TStr Desc=
"",
const bool& BagOfWhiskers=
true,
const bool& RewireNet=
false,
118 const int& KMin=10,
const int& KMax=
Mega(100),
const int& Coverage=10,
const bool& SaveTxtStat=
false,
const bool& PlotBoltzman=
false);
143 double Phi(
const int i)
const {
return PhiV[i]; }
153 TCutInfo(
const int& ClustNodes,
const int& EdgesInside,
const int& CutSize) :
Nodes(ClustNodes),
Edges(EdgesInside),
CutSz(CutSize) { }
154 TCutInfo(
const int& ClustNodes,
const int& EdgesInside,
const int& CutSize,
const TIntV& NIdV) :
169 double GetFracDegOut(
const PUNGraph&
Graph,
double& MxFrac,
double& AvgFrac,
double& MedianFrac,
double& Pct9Frac,
double& Flake)
const;
191 TLocClustStat(
const double& _Alpha,
const int& _KMin,
const int& _KMax,
const double& _KFac,
const int& _Coverage,
const double& _SizeFrac);
195 void Run(
const PUNGraph&
Graph,
const bool& SaveAllSweeps=
false,
const bool& SaveAllCond=
false,
const bool& SaveBestNodesAtK=
false);
198 void AddCut(
const int& ClustSz,
const double& Phi);
201 double FindBestCut(
const int& Nodes,
const TIntSet& TabuNIdSet,
int& BestCutId)
const;
202 const TCutInfo&
FindBestCut(
const int& Nodes=-1)
const;
204 int FindBestCut(
const int& Nodes,
int& Vol,
int& Cut,
double& Phi)
const;
254 void Impose(
const TStr& OutFNm,
const int& TopN,
const bool& Smooth);
264 static void PlotDataset(
const TStr& InFNmWc,
const TStr& OutFNm,
const bool& ImposeNcp=
false,
const bool& VsGraphN=
false);
double GetModRat(const int &GEdges) const
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...
TVec< TNodeSweep > SweepsV
static void PlotDataset(const TStr &InFNmWc, const TStr &OutFNm, const bool &ImposeNcp=false, const bool &VsGraphN=false)
void PlotAvgNcp(const TStr &OutFNm, const TVec< TFltPrV > &NcpVec, const int &MinSz, const double &MaxMinY)
static void BagOfWhiskers2(const PUNGraph &Graph, TFltPrV &SizePhiV)
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...
int GetVol(const int &Nodes) const
Returns the volume of the set of first NodeN nodes in the sweep vector.
void SupportSweep()
After the function ApproxPageRank() has been run the SupportSweep() computes the volume, cut size, node ids, conductance vectors.
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 Conductanc...
int GetCut(const int &Nodes) const
Returns the size of the cut of the first Nodes nodes in the sweep vector.
const TIntV & GetNIdV() const
Vector of node IDs sorted in the random walk order.
void Run(const PUNGraph &Graph, const bool &SaveAllSweeps=false, const bool &SaveAllCond=false, const bool &SaveBestNodesAtK=false)
TVec< TFltPrV > WhiskNcpV
int ApproxPageRank(const int &SeedNode, const double &Eps)
Computes Approximate PageRank from the seed node SeedNId and with tolerance Eps.
TFltPr GetXYAtMinY(const TFltPrV &Ncp, const int &NNodes)
void PlotNcpMin(const TStr &OutFNm, const bool &VsGraphN=false)
void PlotPhiDistr(const int &CmtySz, const TStr &OutFNm, TStr Desc=TStr()) const
void FindBestCut(const int &SeedNode, const int &ClustSz, const double &MinSizeFrac=0.2)
Finds minimum conductance cut in the graph around the seed node.
TSizeTy Len() const
Returns the number of elements in the vector.
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]).
double GetExpEdgesIn(const int &GEdges) const
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]).
void GetBoltzmanCurveStat(const TFltV &TempV, TVec< TFltPrV > &NcpV) const
const TCutInfo & GetKNodeCut(const int &Nodes) const
int Len() const
Returns the support of the approximate random walk, the number of nodes with non-zero PageRank score...
void PlotNCP(const TStr &OutFNm, TStr Desc=TStr()) const
int GetCutEdges() const
Number of edges in the 'best' (minimum conductance) cut.
double GetNormCut(const int &GEdges) const
static double Sqr(const double &x)
void GetEdgesInOut(const PGraph &Graph, const TIntV &NIdV, int &EdgesInX, int &EdgesOutX)
int BestWhiskNodes() const
double GetCutPhi() const
Conductance of the 'best' (minimum conductance) cut.
void PlotRewBestWhisker(const TStr &OutFNm, const bool &VsGraphN=false)
const TCutInfo & GetBestCut() const
void PlotNCPModul(const TStr &OutFNm, TStr Desc=TStr()) const
int BestWhiskEdges() const
double GetExpansion() const
Local-Spectral-Clustering statistics of a given Graph.
static void BagOfWhiskers(const PUNGraph &Graph, TFltPrV &SizePhiV, TFltPr &BestWhisk)
void AddToBestCutH(const PUNGraph &Graph, const TIntV &NIdV, const bool &AddBestCond=true)
Local Spectral Clustering algorithm.
void SaveTxtNcpMin(const TStr &OutFNm, const bool &VsGraphN=false)
int GetRndWalkSup() const
Returns the support of the approximate random walk, the number of nodes with non-zero PageRank score...
void PlotBestWhisker(const TStr &OutFNm, const bool &VsGraphN=false)
double GetCutRatio(const int &GNodes) const
void Save(TSOut &SOut) const
const TFltV & GetPhiV() const
Conducatance of the cut separating first K-nodes in the node-id vector (GetNIdV()) from the rest of t...
void PlotRewNcpMin(const TStr &OutFNm, const bool &VsGraphN=false)
double GetIntDens() const
double FindBestCut(const int &Nodes, const TIntSet &TabuNIdSet, int &BestCutId) const
static double Round(const double &Val)
const TFltPrV & GetBagOfWhiskersV() const
static void MakeExpBins(const TFltPrV &ValV, TFltPrV &NewV)
double Phi(const int i) const
double GetPhi(const int &ValId) const
Returns the conductance of the cut separating the first Nodes nodes in the sweep vector from the rest...
int GetCutVol() const
Volume of the 'best' (minimum conductance) cut.
THash< TInt, TFltV > SizePhiH
void PlotNCPScatter(const TStr &OutFNm, TStr Desc=TStr()) const
void PlotPhiInOut(const TStr &OutFNm, TStr Desc=TStr()) const
TCutInfo(const TCutInfo &CS)
void GetCurveStat(TFltPrV &MeanV, TFltPrV &MedV, TFltPrV &Dec1V, TFltPrV &MinV, TFltPrV &MaxV) const
double GetFracDegOut(const PUNGraph &Graph, double &MxFrac, double &AvgFrac, double &MedianFrac, double &Pct9Frac, double &Flake) const
THash< TInt, TCutInfo > BestCutH
TFltPr GetBestWhisk() const
void SaveTxt(const TStr &OutFNm)
double GetModular(const int &GEdges) const
void ImposeNCP(const TLocClustStat &LcStat2, TStr OutFNm, TStr Desc, TStr Desc1, TStr Desc2) const
const TIntV & GetCutV() const
Edges cut to separate the first K-nodes in the node-id vector (GetNIdV()) from the rest of the graph...
TCutInfo(const int &ClustNodes, const int &EdgesInside, const int &CutSize, const TIntV &NIdV)
const TIntV & GetVolV() const
Volume (sum of the degrees) of first K-nodes in the node-id vector (GetNIdV()).
void PlotNcpTop10(const TStr &OutFNm, TStr Desc, const int &TakeMinN) const
const TCutInfo & GetCutN(const int &N) const
void PlotBestClustDens(TStr OutFNm, TStr Desc=TStr()) const
bool operator<(const TNodeSweep &CS) const
TNcpGraphsBase(const TStr &FNmWc)
bool operator<(const TCutInfo &CS) const
int BestCut() const
Index K of the cut of the minimum conductance around the seed node.
int GetNId(const int &NodeN) const
Returns the ID of the NodeN-th node in the sweep vector.
TCutInfo(const PUNGraph &G, const TIntV &ClustNIdV, bool TakeNIdV=false)
TNodeSweep(const TNodeSweep &NS)
void PlotBoltzmanCurve(const TStr &OutFNm, TStr Desc=TStr()) const
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]).
void AddCut(const TIntV &NIdV)
TNodeSweep(const int &SeedNode, const TIntV &SweepNIdV, const TFltV &PhiNIdV)
void Save(TSOut &SOut) const
double BestWhiskPhi() const
void SetGraph(const PUNGraph &GraphPt)
void SaveTxtInfo(const TStr &OutFNmPref, const TStr &Desc, const bool &SetMaxAt1) const
int BestCutNodes() const
Number of nodes inside the 'best' (minimum conductance) cut.
double GetXAtMinY(const TFltPrV &Ncp, const int &NNodes)
void Impose(const TStr &OutFNm, const int &TopN, const bool &Smooth)
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)
Local-Spectral-Clustering for a set of graphs (loads ncp-*.tab files)
TLocClust(const PUNGraph &GraphPt, const double &AlphaVal)
int NId(const int i) const
TCutInfo(const int &ClustNodes, const int &EdgesInside, const int &CutSize)
TLocClustStat(const double &_Alpha, const int &_KMin, const int &_KMax, const double &_KFac, const int &_Coverage, const double &_SizeFrac)