Utility functions for BigCLAM, Coda.
More...
#include <agmfast.h>
Utility functions for BigCLAM, Coda.
Definition at line 126 of file agmfast.h.
template<class PGraph >
static void TAGMFastUtil::GenHoldOutPairs |
( |
const PGraph & |
G, |
|
|
TVec< TIntSet > & |
HoldOutSet, |
|
|
double |
HOFrac, |
|
|
TRnd & |
Rnd |
|
) |
| |
|
inlinestatic |
Definition at line 159 of file agmfast.h.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Gen(), TRnd::GetUniDevInt(), gfDirected, HasGraphFlag, and TMath::Round().
Referenced by TCoda::FindComsByCV(), and TCoda::SetHoldOut().
160 TIntPrV EdgeV(G->GetEdges(), 0);
161 for (
typename PGraph::TObj::TEdgeI EI = G->BegEI(); EI < G->EndEI(); EI++) {
162 EdgeV.
Add(
TIntPr(EI.GetSrcNId(), EI.GetDstNId()));
167 HoldOutSet.
Gen(G->GetNodes());
168 int HOTotal = int(HOFrac * G->GetNodes() * (G->GetNodes() - 1) / 2.0);
169 if (GraphType) { HOTotal *= 2;}
171 int HOEdges = (int)
TMath::Round(HOFrac * G->GetEdges());
172 printf(
"holding out %d edges...\n", HOEdges);
173 for (
int he = 0; he < (int) HOEdges; he++) {
174 HoldOutSet[EdgeV[he].Val1].AddKey(EdgeV[he].Val2);
175 if (! GraphType) { HoldOutSet[EdgeV[he].Val2].AddKey(EdgeV[he].Val1); }
178 printf(
"%d Edges hold out\n", HOCnt);
179 while(HOCnt++ < HOTotal) {
182 if (SrcNID == DstNID) {
continue; }
183 HoldOutSet[SrcNID].AddKey(DstNID);
184 if (! GraphType) { HoldOutSet[DstNID].AddKey(SrcNID); }
TPair< TInt, TInt > TIntPr
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
static double Round(const double &Val)
directed graph (TNGraph, TNEGraph), else graph is undirected TUNGraph
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
int GetUniDevInt(const int &Range=0)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
template<class PGraph >
static double TAGMFastUtil::GetConductance |
( |
const PGraph & |
Graph, |
|
|
const TIntSet & |
CmtyS, |
|
|
const int |
Edges |
|
) |
| |
|
inlinestatic |
Definition at line 131 of file agmfast.h.
References gfDirected, HasGraphFlag, THashSet< TKey, THashFunc >::IsKey(), and THashSet< TKey, THashFunc >::Len().
Referenced by GetNIdPhiV().
134 if (GraphType) { Edges2 = Edges >= 0 ? Edges : Graph->GetEdges(); }
135 else { Edges2 = Edges >= 0 ? 2 * Edges : Graph->GetEdges(); }
136 int Vol = 0, Cut = 0;
138 for (
int i = 0; i < CmtyS.
Len(); i++) {
139 if (! Graph->IsNode(CmtyS[i])) {
continue; }
140 typename PGraph::TObj::TNodeI NI = Graph->GetNI(CmtyS[i]);
141 for (
int e = 0; e < NI.GetOutDeg(); e++) {
142 if (! CmtyS.
IsKey(NI.GetOutNId(e))) { Cut += 1; }
144 Vol += NI.GetOutDeg();
148 if (2 * Vol > Edges2) { Phi = Cut / double (Edges2 - Vol); }
149 else if (Vol == 0) { Phi = 0.0; }
150 else { Phi = Cut / double(Vol); }
152 if (Vol == Edges2) { Phi = 1.0; }
bool IsKey(const TKey &Key) const
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
directed graph (TNGraph, TNEGraph), else graph is undirected TUNGraph
template<class PGraph >
static void TAGMFastUtil::GetNbhCom |
( |
const PGraph & |
Graph, |
|
|
const int |
NID, |
|
|
TIntSet & |
NBCmtyS |
|
) |
| |
|
inlinestatic |
template<class PGraph >
static void TAGMFastUtil::GetNIdPhiV |
( |
const PGraph & |
G, |
|
|
TFltIntPrV & |
NIdPhiV |
|
) |
| |
|
inlinestatic |
Definition at line 198 of file agmfast.h.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Gen(), GetConductance(), and TExeTm::GetTmStr().
199 NIdPhiV.
Gen(G->GetNodes(), 0);
200 const int Edges = G->GetEdges();
203 for (
typename PGraph::TObj::TNodeI NI = G->BegNI(); NI < G->EndNI(); NI++) {
204 TIntSet NBCmty(NI.GetDeg() + 1);
206 if (NI.GetDeg() < 5) {
209 TAGMFastUtil::GetNbhCom<PGraph>(G, NI.GetId(), NBCmty);
214 printf(
"conductance computation completed [%s]\n", RunTm.
GetTmStr());
TPair< TFlt, TInt > TFltIntPr
static double GetConductance(const PGraph &Graph, const TIntSet &CmtyS, const int Edges)
const char * GetTmStr() const
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.
The documentation for this class was generated from the following file: