#include <cliques.h>
|
static void | GetRelativeComplement (const THashSet< TInt > &A, const THashSet< TInt > &B, THashSet< TInt > &Complement) |
|
static void | GetIntersection (const THashSet< TInt > &A, const THashSet< TInt > &B, THashSet< TInt > &C) |
|
static int | Intersection (const THashSet< TInt > &A, const THashSet< TInt > &B) |
|
static void | CalculateOverlapMtx (const TVec< TIntV > &MaxCliques, int MinNodeOverlap, TVec< TIntV > &OverlapMtx) |
|
static PUNGraph | CalculateOverlapMtx (const TVec< TIntV > &MaxCliques, int MinNodeOverlap) |
|
static void | GetOverlapCliques (const TVec< TIntV > &OverlapMtx, int MinNodeOverlap, TVec< TIntV > &CliqueIdVV) |
|
static void | GetOverlapCliques (const TVec< TIntV > &OverlapMtx, const TVec< TIntV > &MaxCliques, double MinOverlapFrac, TVec< TIntV > &CliqueIdVV) |
|
static void | GetMaxCliques (const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &MaxCliques) |
| Enumerate maximal cliques of the network on more than MinMaxCliqueSize nodes. More...
|
|
static void | GetCPMCommunities (const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &Communities) |
| Clique Percolation method communities. More...
|
|
Definition at line 8 of file cliques.h.
TCliqueOverlap::TCliqueOverlap |
( |
| ) |
|
|
inline |
Definition at line 29 of file cliques.h.
TVec< TIntV > * m_maxCliques
void TCliqueOverlap::CalculateOverlapMtx |
( |
const TVec< TIntV > & |
MaxCliques, |
|
|
int |
MinNodeOverlap, |
|
|
TVec< TIntV > & |
OverlapMtx |
|
) |
| |
|
static |
Definition at line 127 of file cliques.cpp.
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]); }
TSizeTy Len() const
Returns the number of elements in the vector.
void Gen(const int &ExpectVals)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
int AddKey(const TKey &Key)
const TVal & Last() const
Returns a reference to the last element of the vector.
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
static int Intersection(const THashSet< TInt > &A, const THashSet< TInt > &B)
Vector is a sequence TVal objects representing an array that can change in size.
PUNGraph TCliqueOverlap::CalculateOverlapMtx |
( |
const TVec< TIntV > & |
MaxCliques, |
|
|
int |
MinNodeOverlap |
|
) |
| |
|
static |
Definition at line 152 of file cliques.cpp.
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) {
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
void Gen(const int &ExpectVals)
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.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
static int Intersection(const THashSet< TInt > &A, const THashSet< TInt > &B)
Vector is a sequence TVal objects representing an array that can change in size.
Definition at line 73 of file cliques.cpp.
75 if (CAND.
Len()==0)
return;
84 while(EXT.
Len() != 0) {
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
TSizeTy Len() const
Returns the number of elements in 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)
void Expand(const THashSet< TInt > &SUBG, THashSet< TInt > &CAND)
TVec< TIntV > * m_maxCliques
void Pack()
Reduces vector capacity (frees memory) to match its size.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void DelLast()
Removes the last element of the vector.
int GetNodeIdWithMaxDeg(const THashSet< TInt > &Set) const
void TCliqueOverlap::GetCPMCommunities |
( |
const PUNGraph & |
G, |
|
|
int |
MinMaxCliqueSize, |
|
|
TVec< TIntV > & |
Communities |
|
) |
| |
|
static |
Clique Percolation method communities.
Definition at line 224 of file cliques.cpp.
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]];
247 CmtySet.
GetKeyV(NIdCmtyVV.Last());
248 NIdCmtyVV.Last().Sort();
250 printf(
"done [%s].\n", ExeTm.
GetStr());
void Clr(const bool &DoDel=true, const int &NoDelLim=-1)
void AddKeyV(const TVec< TKey > &KeyV)
int GetEdges() const
Returns the number of edges in the graph.
void GetKeyV(TVec< TKey > &KeyV) const
static void GetMaxCliques(const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &MaxCliques)
Enumerate maximal cliques of the network on more than MinMaxCliqueSize nodes.
int GetNodes() const
Returns the number of nodes in the graph.
const char * GetStr() const
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.
Definition at line 13 of file cliques.cpp.
bool IsKey(const TKey &Key) const
int AddKey(const TKey &Key)
void TCliqueOverlap::GetMaxCliques |
( |
const PUNGraph & |
G, |
|
|
int |
MinMaxCliqueSize, |
|
|
TVec< TIntV > & |
MaxCliques |
|
) |
| |
|
static |
Enumerate maximal cliques of the network on more than MinMaxCliqueSize nodes.
Definition at line 217 of file cliques.cpp.
219 MaxCliques.
Clr(
false);
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
void GetMaximalCliques(const PUNGraph &G, int MinMaxCliqueSize, TVec< TIntV > &MaxCliques)
void TCliqueOverlap::GetMaximalCliques |
( |
const PUNGraph & |
G, |
|
|
int |
MinMaxCliqueSize, |
|
|
TVec< TIntV > & |
MaxCliques |
|
) |
| |
Definition at line 108 of file cliques.cpp.
119 TInt nId = NI.GetId();
Node iterator. Only forward iteration (operator++) is supported.
int GetNodes() const
Returns the number of nodes in the graph.
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
int AddKey(const TKey &Key)
void Expand(const THashSet< TInt > &SUBG, THashSet< TInt > &CAND)
TVec< TIntV > * m_maxCliques
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
void TCliqueOverlap::GetNbrs |
( |
int |
NId, |
|
|
THashSet< TInt > & |
Nbrs |
|
) |
| const |
|
private |
Definition at line 35 of file cliques.cpp.
Node iterator. Only forward iteration (operator++) is supported.
int GetDeg() const
Returns degree of the current node.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
int AddKey(const TKey &Key)
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
int TCliqueOverlap::GetNodeIdWithMaxDeg |
( |
const THashSet< TInt > & |
Set | ) |
const |
|
private |
Definition at line 41 of file cliques.cpp.
46 int nId = it.GetKey();
48 if (maxDeg < deg) { maxDeg=deg;
id=nId; }
int GetDeg() const
Returns degree of the current node.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
void TCliqueOverlap::GetOverlapCliques |
( |
const TVec< TIntV > & |
OverlapMtx, |
|
|
int |
MinNodeOverlap, |
|
|
TVec< TIntV > & |
CliqueIdVV |
|
) |
| |
|
static |
Definition at line 177 of file cliques.cpp.
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) {
TSizeTy Len() const
Returns the number of elements in the vector.
const TVal & Last() const
Returns a reference to the last element of the vector.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void TCliqueOverlap::GetOverlapCliques |
( |
const TVec< TIntV > & |
OverlapMtx, |
|
|
const TVec< TIntV > & |
MaxCliques, |
|
|
double |
MinOverlapFrac, |
|
|
TVec< TIntV > & |
CliqueIdVV |
|
) |
| |
|
static |
Definition at line 194 of file cliques.cpp.
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){
TSizeTy Len() const
Returns the number of elements in the vector.
const TVal & Last() const
Returns a reference to the last element of the vector.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition at line 6 of file cliques.cpp.
8 const int nId = it.GetKey();
bool IsKey(const TKey &Key) const
int AddKey(const TKey &Key)
Definition at line 23 of file cliques.cpp.
27 if (B.
IsKey(it.GetKey())) n++;
30 if (A.
IsKey(it.GetKey())) n++;
bool IsKey(const TKey &Key) const
Definition at line 53 of file cliques.cpp.
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; }
Node iterator. Only forward iteration (operator++) is supported.
bool IsKey(const TKey &Key) const
int GetDeg() const
Returns degree of the current node.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
int TCliqueOverlap::m_minMaxCliqueSize |
|
private |
TIntV TCliqueOverlap::m_Q |
|
private |
The documentation for this class was generated from the following files: