7 template<
typename PGraph>
double GetModularity(
const PGraph& G,
const TIntV& NIdV,
int GEdges=-1);
10 template<
typename PGraph>
double GetModularity(
const PGraph& G,
const TCnComV& CmtyV,
int GEdges=-1);
14 template<
typename PGraph>
void GetEdgesInOut(
const PGraph& Graph,
const TIntV& NIdV,
int& EdgesInX,
int& EdgesOutX);
38 namespace TSnapDetail {
45 template<
typename PGraph>
47 if (GEdges == -1) { GEdges = Graph->GetEdges(); }
48 double EdgesIn = 0.0, EEdgesIn = 0.0;
50 for (
int e = 0; e < NIdV.
Len(); e++) {
53 for (
int e1 = 0; e1 < NIdV.
Len(); e1++) {
54 typename PGraph::TObj::TNodeI NI = Graph->GetNI(NIdV[e1]);
55 EEdgesIn += NI.GetOutDeg();
56 for (
int i = 0; i < NI.GetOutDeg(); i++) {
57 if (NIdSet.IsKey(NI.GetOutNId(i))) { EdgesIn += 1; }
60 EEdgesIn = EEdgesIn*EEdgesIn / (2.0*GEdges);
61 if ((EdgesIn - EEdgesIn) == 0) {
return 0; }
62 else {
return (EdgesIn - EEdgesIn) / (2.0*GEdges); }
65 template<
typename PGraph>
67 if (GEdges == -1) { GEdges = G->GetEdges(); }
68 double Modularity = 0;
69 for (
int c = 0; c < CmtyV.
Len(); c++) {
75 template<
typename PGraph>
80 for (
int e = 0; e < NIdV.
Len(); e++) {
83 for (
int e = 0; e < NIdV.
Len(); e++) {
84 typename PGraph::TObj::TNodeI NI = Graph->GetNI(NIdV[e]);
85 for (
int i = 0; i < NI.GetOutDeg(); i++) {
86 if (NIdSet.IsKey(NI.GetOutNId(i))) { EdgesIn += 1; }
87 else { EdgesOut += 1; }
double CommunityGirvanNewman(PUNGraph &Graph, TCnComV &CmtyV)
TSizeTy Len() const
Returns the number of elements in the vector.
double InfomapOnline(PUNGraph &Graph, int n1, int n2, TIntFltH &PAlpha, double &SumPAlphaLogPAlpha, TIntFltH &Qi, TIntH &Module, int &Br, TCnComV &CmtyV)
void ReebSimplify(PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse)
void GetEdgesInOut(const PGraph &Graph, const TIntV &NIdV, int &EdgesInX, int &EdgesOutX)
void CmtyEvolutionFileBatch(TStr InFNm, TIntIntHH &sizesCont, TIntIntHH &cCont, TIntIntVH &edges, double alpha, double beta, int CmtyAlg)
void CmtyEvolutionFileBatchV(TStr InFNm, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges, double alpha, double beta, int CmtyAlg)
int AddKey(const TKey &Key)
TStr CmtyTest(TStr InFNm, int CmtyAlg)
double GetModularity(const PGraph &G, const TIntV &NIdV, int GEdges=-1)
void CmtyEvolutionJson(TStr &Json, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges)
double CommunityCNM(const PUNGraph &Graph, TCnComV &CmtyV)
void ReebRefine(PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse)
double Infomap(PUNGraph &Graph, TCnComV &CmtyV)
void CmtyGirvanNewmanStep(PUNGraph &Graph, TIntV &Cmty1, TIntV &Cmty2)
A single step of Girvan-Newman clustering procedure.