本文整理汇总了C++中TIntSet::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntSet::Clr方法的具体用法?C++ TIntSet::Clr怎么用?C++ TIntSet::Clr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntSet
的用法示例。
在下文中一共展示了TIntSet::Clr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGroupSet
// Helper: Return GroupSet based on NodeID
void GetGroupSet(int NId, TIntSet& GroupSet) {
GroupSet.Clr();
switch (NId) {
case 0:
GroupSet.AddKey(2);
GroupSet.AddKey(4);
GroupSet.AddKey(5);
break;
case 1:
// Empty Set
break;
case 2:
GroupSet.AddKey(0);
GroupSet.AddKey(3);
GroupSet.AddKey(5);
break;
case 3:
GroupSet.AddKey(0);
break;
case 4:
GroupSet.AddKey(0);
break;
case 5:
GroupSet.AddKey(0);
GroupSet.AddKey(1);
break;
default:
ASSERT_FALSE(true); // NId Outside Graph Construction FAIL
break;
}
}
示例2: GetCPMCommunities
/// Clique Percolation method communities
void TCliqueOverlap::GetCPMCommunities(const PUNGraph& G, int MinMaxCliqueSize, TVec<TIntV>& NIdCmtyVV) {
printf("Clique Percolation Method\n");
TExeTm ExeTm;
TVec<TIntV> MaxCliques;
TCliqueOverlap::GetMaxCliques(G, MinMaxCliqueSize, MaxCliques);
// op RS 2012/05/15, commented out next line, a parameter is missing,
// creating a warning on OS X
// printf("...%d cliques found\n");
// get clique overlap matrix (graph)
PUNGraph OverlapGraph = TCliqueOverlap::CalculateOverlapMtx(MaxCliques, MinMaxCliqueSize-1);
printf("...overlap matrix (%d, %d)\n", G->GetNodes(), G->GetEdges());
// connected components are communities
TCnComV CnComV;
TSnap::GetWccs(OverlapGraph, CnComV);
NIdCmtyVV.Clr(false);
TIntSet CmtySet;
for (int c = 0; c < CnComV.Len(); c++) {
CmtySet.Clr(false);
for (int i = 0; i <CnComV[c].Len(); i++) {
const TIntV& CliqueNIdV = MaxCliques[CnComV[c][i]];
CmtySet.AddKeyV(CliqueNIdV);
}
NIdCmtyVV.Add();
CmtySet.GetKeyV(NIdCmtyVV.Last());
NIdCmtyVV.Last().Sort();
}
printf("done [%s].\n", ExeTm.GetStr());
}
示例3: GenPrefAttach
/// Barabasi-Albert model of scale-free graphs.
/// The graph has power-law degree distribution.
/// See: Emergence of scaling in random networks by Barabasi and Albert.
/// URL: http://arxiv.org/abs/cond-mat/9910332
PUNGraph GenPrefAttach(const int& Nodes, const int& NodeOutDeg, TRnd& Rnd) {
PUNGraph GraphPt = PUNGraph::New();
TUNGraph& Graph = *GraphPt;
Graph.Reserve(Nodes, NodeOutDeg*Nodes);
TIntV NIdV(NodeOutDeg*Nodes, 0);
// first edge
Graph.AddNode(0); Graph.AddNode(1);
NIdV.Add(0); NIdV.Add(1);
Graph.AddEdge(0, 1);
TIntSet NodeSet;
for (int node = 2; node < Nodes; node++) {
NodeSet.Clr(false);
while (NodeSet.Len() < NodeOutDeg && NodeSet.Len() < node) {
NodeSet.AddKey(NIdV[TInt::Rnd.GetUniDevInt(NIdV.Len())]);
}
const int N = Graph.AddNode();
for (int i = 0; i < NodeSet.Len(); i++) {
Graph.AddEdge(N, NodeSet[i]);
NIdV.Add(N);
NIdV.Add(NodeSet[i]);
}
}
return GraphPt;
}