8 const int nId = it.GetKey();
27 if (B.
IsKey(it.GetKey())) n++;
30 if (A.
IsKey(it.GetKey())) n++;
46 int nId = it.GetKey();
48 if (maxDeg < deg) { maxDeg=deg;
id=nId; }
55 int maxIntersection = -1;
58 int nId = it.GetKey();
62 int curIntersection = 0;
63 for (
int i=0; i<deg; i++) {
65 if (CAND.
IsKey(nbrId)) curIntersection++;
68 if (maxIntersection < curIntersection) { maxIntersection=curIntersection;
id=nId; }
75 if (CAND.
Len()==0)
return;
84 while(EXT.
Len() != 0) {
119 TInt nId = NI.GetId();
130 int n = MaxCliques.
Len();
133 for (
int i=0; i<n; i++) {
134 const int len = MaxCliques[i].
Len();
136 if (len < MinNodeOverlap) {
continue; }
138 for (
int j=0; j<len; j++) { set.
AddKey(MaxCliques[i][j]); }
143 for (
int i=0; i<n; i++) OverlapMtx[i].Gen(n);
145 for (
int i=0; i<n; i++) {
146 OverlapMtx[i][i] = cliques[i].
Len();
147 for (
int j=i+1; j<n; j++) {
148 OverlapMtx[i][j] =
Intersection(cliques[i], cliques[j]); }
153 const int n = MaxCliques.
Len();
156 for (
int i=0; i<n; i++) {
157 const int len = MaxCliques[i].
Len();
159 if (len < MinNodeOverlap) {
continue; }
161 for (
int j=0; j<len; j++) { set.
AddKey(MaxCliques[i][j]); }
165 for (
int i=0; i < n; i++) {
168 for (
int i=0; i<n; i++) {
169 for (
int j=i+1; j<n; j++) {
170 if (
Intersection(cliques[i], cliques[j]) >= MinNodeOverlap) {
178 int n = OverlapMtx.
Len();
179 for (
int i=0; i<n; i++) {
180 bool isCommunity =
false;
181 for (
int j=i+1; j<n; j++) {
182 if (OverlapMtx[i][j] >= MinNodeOverlap) {
195 int n = OverlapMtx.
Len();
196 for(
int i=0; i<n; i++){
197 bool isCommunity =
false;
198 int size1 = MaxCliques[i].
Len();
199 for(
int j=i+1; j<n; j++){
200 int size2 = MaxCliques[j].
Len();
201 double ratio = OverlapMtx[i][j];
202 if(size1 < size2) ratio /= size1;
204 if(ratio >= MinOverlapFrac){
219 MaxCliques.
Clr(
false);
225 printf(
"Clique Percolation Method\n");
238 NIdCmtyVV.
Clr(
false);
240 for (
int c = 0; c < CnComV.Len(); c++) {
242 for (
int i = 0; i <CnComV[c].Len(); i++) {
243 const TIntV& CliqueNIdV = MaxCliques[CnComV[c][i]];
250 printf(
"done [%s].\n", ExeTm.
GetStr());
void Clr(const bool &DoDel=true, const int &NoDelLim=-1)
static void GetRelativeComplement(const THashSet< TInt > &A, const THashSet< TInt > &B, THashSet< TInt > &Complement)
void GetNbrs(int NId, THashSet< TInt > &Nbrs) const
void AddKeyV(const TVec< TKey > &KeyV)
static void GetCPMCommunities(const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &Communities)
Clique Percolation method communities.
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
int GetEdges() const
Returns the number of edges in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
Node iterator. Only forward iteration (operator++) is supported.
void GetKeyV(TVec< TKey > &KeyV) const
void Gen(const int &ExpectVals)
static void GetMaxCliques(const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &MaxCliques)
Enumerate maximal cliques of the network on more than MinMaxCliqueSize nodes.
bool IsKey(const TKey &Key) const
int GetNodes() const
Returns the number of nodes in the graph.
int GetDeg() const
Returns degree of the current node.
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
static void GetOverlapCliques(const TVec< TIntV > &OverlapMtx, int MinNodeOverlap, TVec< TIntV > &CliqueIdVV)
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
void DelKey(const TKey &Key)
int MaxNbrsInCANDNodeId(const THashSet< TInt > &SUBG, const THashSet< TInt > &CAND) const
static void GetIntersection(const THashSet< TInt > &A, const THashSet< TInt > &B, THashSet< TInt > &C)
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New().
int AddKey(const TKey &Key)
const TVal & Last() const
Returns a reference to the last element of the vector.
void Expand(const THashSet< TInt > &SUBG, THashSet< TInt > &CAND)
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph.
TVec< TIntV > * m_maxCliques
void Pack()
The vector reduces its capacity (frees memory) to match its size.
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
const char * GetStr() const
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
void DelLast()
Removes the last element of the vector.
static int Intersection(const THashSet< TInt > &A, const THashSet< TInt > &B)
static void CalculateOverlapMtx(const TVec< TIntV > &MaxCliques, int MinNodeOverlap, TVec< TIntV > &OverlapMtx)
void GetWccs(const PGraph &Graph, TCnComV &CnComV)
Returns all weakly connected components in a Graph.
void GetMaximalCliques(const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &MaxCliques)
int GetNodeIdWithMaxDeg(const THashSet< TInt > &Set) const
Vector is a sequence TVal objects representing an array that can change in size.