本文整理汇总了C++中TExeTm::GetStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TExeTm::GetStr方法的具体用法?C++ TExeTm::GetStr怎么用?C++ TExeTm::GetStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TExeTm
的用法示例。
在下文中一共展示了TExeTm::GetStr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintGraphStatTable
void PrintGraphStatTable(const PGraph& G, TStr OutFNm, TStr Desc="") {
TFltPrV DegCCfV;
int64 ClosedTriads, OpenTriads;
int FullDiam;
double EffDiam;
TSnap::PrintInfo(G, OutFNm);
TExeTm ExeTm; printf("C");
const double CCF = TSnap::GetClustCf(G, DegCCfV, ClosedTriads, OpenTriads);
printf("[%s]D", ExeTm.GetStr());
TSnap::GetBfsEffDiam(G, 1000, false, EffDiam, FullDiam);
printf("[%s]CC", ExeTm.GetStr());
PGraph WCC = TSnap::GetMxWcc(G);
PGraph SCC = TSnap::GetMxScc(G);
printf("[%s]\n", ExeTm.GetStr());
FILE* F = stdout;
if (! OutFNm.Empty()) {
F = fopen(TStr::Fmt("%s.html", OutFNm.CStr()).CStr(), "wt"); }
fprintf(F, "\n");
fprintf(F, "<table id=\"datatab\" summary=\"Dataset statistics\">\n");
fprintf(F, " <tr> <th colspan=\"2\">Dataset statistics</th> </tr>\n");
fprintf(F, " <tr><td>Nodes</td> <td>%d</td></tr>\n", G->GetNodes());
fprintf(F, " <tr><td>Edges</td> <td>%d</td></tr>\n", G->GetEdges());
fprintf(F, " <tr><td>Nodes in largest WCC</td> <td>%d (%.3f)</td></tr>\n", WCC->GetNodes(), WCC->GetNodes()/double(G->GetNodes()));
fprintf(F, " <tr><td>Edges in largest WCC</td> <td>%d (%.3f)</td></tr>\n", WCC->GetEdges(), WCC->GetEdges()/double(G->GetEdges()));
fprintf(F, " <tr><td>Nodes in largest SCC</td> <td>%d (%.3f)</td></tr>\n", SCC->GetNodes(), SCC->GetNodes()/double(G->GetNodes()));
fprintf(F, " <tr><td>Edges in largest SCC</td> <td>%d (%.3f)</td></tr>\n", SCC->GetEdges(), SCC->GetEdges()/double(G->GetEdges()));
fprintf(F, " <tr><td>Average clustering coefficient</td> <td>%.4f</td></tr>\n", CCF);
fprintf(F, " <tr><td>Number of triangles</td> <td>%s</td></tr>\n", TUInt64(ClosedTriads).GetStr().CStr());
fprintf(F, " <tr><td>Fraction of closed triangles</td> <td>%.4g</td></tr>\n", ClosedTriads/double(ClosedTriads+OpenTriads));
fprintf(F, " <tr><td>Diameter (longest shortest path)</td> <td>%d</td></tr>\n", FullDiam);
fprintf(F, " <tr><td>90-percentile effective diameter</td> <td>%.2g</td></tr>\n", EffDiam);
fprintf(F, "</table>\n");
fprintf(F, "<br>\n");
if (! OutFNm.Empty()) {
fprintf(F, "\n<table id=\"datatab\" summary=\"Table of datasets\">\n");
fprintf(F, "<tr>\n");
fprintf(F, " <th>File</th>\n");
fprintf(F, " <th>Description</th>\n");
fprintf(F, "</tr>\n");
fprintf(F, "<tr>\n");
fprintf(F, " <td><a href=\"%s.txt.gz\">%s.txt.gz</a></td>\n", OutFNm.CStr(), OutFNm.CStr());
fprintf(F, " <td>%s</td>\n", Desc.CStr());
fprintf(F, "</tr>\n");
fprintf(F, "</table>\n");
fclose(F);
TSnap::SaveEdgeList(G, OutFNm+".txt", Desc);
}
}
示例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: GP
void TTop2FriendNet::PlotPick2VsProb2nd(const PWgtNet& Net, const int& NRuns, const double& StepP, const TStr& OutFNm,
TStr Desc, bool PlotTop2, bool PlotBtm2, bool PlotRnd2) {
TTop2FriendNet Top2(Net); Net->MulEdgeWgt(-1.0);
TTop2FriendNet Btm2(Net); Net->MulEdgeWgt(-1.0); // change back
THash<TFlt, TMom> Top2H, Btm2H, Rnd2H;
for (int run = 0; run < NRuns; run++) {
TExeTm ExeTm;
printf("run %d\n", run);
for (double p = 0; p <= 1; p += StepP) {
if (PlotTop2) { Top2H.AddDat(p).Add(Top2.GetTop2WccSz(p)); }
if (PlotBtm2) { Btm2H.AddDat(p).Add(Btm2.GetTop2WccSz(p)); }
if (PlotRnd2) { Rnd2H.AddDat(p).Add(Top2.GetRnd2WccSz(p)); }
printf(".");
}
printf("[%s]\n", ExeTm.GetStr());
TFltTrV Top2V, Btm2V, Rnd2V;
GetAvgSDevV(Top2H, Top2V);
GetAvgSDevV(Btm2H, Btm2V);
GetAvgSDevV(Rnd2H, Rnd2V);
TGnuPlot GP("ccVsP-"+OutFNm, TStr::Fmt("%s (%d, %d, %f)", Desc.CStr(), Net->GetNodes(),
Net->GetEdges(), Net->GetEdgeWgt()));
GP.SetXYLabel("Prob of taking 2nd edge", "Size of largest connected component");
if (! Top2V.Empty()) { GP.AddErrBar(Top2V, "TOP", ""); }
if (! Rnd2V.Empty()) { GP.AddErrBar(Rnd2V, "RND", ""); }
if (! Btm2V.Empty()) { GP.AddErrBar(Btm2V, "BTM", ""); }
GP.SavePng();
}
}
示例4: ReinforceEdges
// IN-OUT edges are swapped (so that the prog runs faster)
// Send message via IN edge proportional to the OUT edge weight
void TWgtNet::ReinforceEdges(const int& NIters) {
THash<TInt, TFlt> OutWgtSumH;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
double wgt = 0;
for (int e = 0; e < NI.GetOutDeg(); e++) {
wgt += NI.GetOutEDat(e); }
OutWgtSumH.AddDat(NI.GetId(), wgt);
}
printf("Reinforcing edges for %d iterations\n", NIters);
// iterate
TExeTm ExeTm;
for (int iter = 0; iter < NIters; iter++) {
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
const double X = TInt::Rnd.GetUniDev() * OutWgtSumH.GetDat(NI.GetId());
double x = 0; int e = 0;
for ( ; x + NI.GetOutEDat(e) < X; e++) {
x += NI.GetOutEDat(e); }
IAssert(IsEdge(NI.GetOutNId(e), NI.GetId()));
GetEDat(NI.GetOutNId(e), NI.GetId()) += 1; // reinforce the edge
OutWgtSumH.GetDat(NI.GetOutNId(e)) += 1;
}
if (iter % (NIters/100) == 0) {
printf("\r%d [%s]", iter, ExeTm.GetStr());
}
}
printf(" done.\n");
}
示例5: GetNextFqItemSets
int TTrawling::GetNextFqItemSets(const int& FqItemsetLen) {
TExeTm ExeTm;
/* // slow
GenCandidates(); // CurItemH --> CandItemH
printf(" S[%d][%s]", CandItemH.Len(), ExeTm.GetStr());
CountSupport(); // set counters in CandItemH
printf("T[%s]", ExeTm.GetStr());
ThresholdSupp(); // CandItemH --> CurItemH
printf(" Items: %d\n", CurItemH.Len());*/
GenCandAndCntSupp(FqItemsetLen);
printf(" cur: %d cand: %d [%s]", CurItemH.Len(), CandItemH.Len(), ExeTm.GetStr());
CurItemH.Swap(CandItemH);
return CurItemH.Len();
}
示例6: Graph
TUNGraphMtx::TUNGraphMtx(const PUNGraph& GraphPt) : Graph() {
Graph = GraphPt;
if (! CheckNodeIds()) {
printf(" Renumbering %d nodes....", GraphPt->GetNodes());
TExeTm ExeTm;
Graph = TSnap::ConvertGraph<PUNGraph>(GraphPt, true);
/*TIntSet NIdSet;
for (TUNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
NIdSet.AddKey(NI.GetId());
}
Graph = TUNGraph::New(); *Graph = *GraphPt; */
printf("done [%s]\n", ExeTm.GetStr());
}
}
示例7: GetInvParticipRat
void GetInvParticipRat(const PUNGraph& Graph, int MaxEigVecs, int TimeLimit, TFltPrV& EigValIprV) {
TUNGraphMtx GraphMtx(Graph);
TFltVV EigVecVV;
TFltV EigValV;
TExeTm ExeTm;
if (MaxEigVecs<=1) { MaxEigVecs=1000; }
int EigVecs = TMath::Mn(Graph->GetNodes(), MaxEigVecs);
printf("start %d vecs...", EigVecs);
try {
TSparseSVD::Lanczos2(GraphMtx, EigVecs, TimeLimit, ssotFull, EigValV, EigVecVV, false);
} catch(...) {
printf("\n ***EXCEPTION: TRIED %d GOT %d values** \n", EigVecs, EigValV.Len()); }
printf(" ***TRIED %d GOT %d values in %s\n", EigVecs, EigValV.Len(), ExeTm.GetStr());
TFltV EigVec;
EigValIprV.Clr();
if (EigValV.Empty()) { return; }
for (int v = 0; v < EigVecVV.GetCols(); v++) {
EigVecVV.GetCol(v, EigVec);
EigValIprV.Add(TFltPr(EigValV[v], GetInvParticipRat(EigVec)));
}
EigValIprV.Sort();
}
示例8: GenRewire
/// Rewire a bipartite graph. Keeps node degrees as is but randomly rewires the
/// edges. Use this function to generate a random graph with the same degree
/// sequence as the OrigGraph.
/// See: On the uniform generation of random graphs with prescribed degree
/// sequences by R. Milo, N. Kashtan, S. Itzkovitz, M. E. J. Newman, U. Alon
/// URL: http://arxiv.org/abs/cond-mat/0312028
PBPGraph GenRewire(const PBPGraph& OrigGraph, const int& NSwitch, TRnd& Rnd) {
const int Nodes = OrigGraph->GetNodes();
const int Edges = OrigGraph->GetEdges();
PBPGraph GraphPt = TBPGraph::New();
TBPGraph& Graph = *GraphPt;
Graph.Reserve(Nodes, -1);
TExeTm ExeTm;
// generate a graph that satisfies the constraints
printf("Randomizing edges (%d, %d)...\n", Nodes, Edges);
TIntPrSet EdgeSet(Edges);
for (TBPGraph::TNodeI NI = OrigGraph->BegLNI(); NI < OrigGraph->EndLNI(); NI++) {
const int NId = NI.GetId();
for (int e = 0; e < NI.GetOutDeg(); e++) {
EdgeSet.AddKey(TIntPr(NId, NI.GetOutNId(e))); } // edges left-->right
Graph.AddNode(NI.GetId(), true); } // left nodes
for (TBPGraph::TNodeI NI = OrigGraph->BegRNI(); NI < OrigGraph->EndRNI(); NI++) {
Graph.AddNode(NI.GetId(), false); } // right nodes
IAssert(EdgeSet.Len() == Edges);
// edge switching
uint skip=0;
for (uint swps = 0; swps < 2*uint(Edges)*uint(NSwitch); swps++) {
const int keyId1 = EdgeSet.GetRndKeyId(Rnd);
const int keyId2 = EdgeSet.GetRndKeyId(Rnd);
if (keyId1 == keyId2) { skip++; continue; }
const TIntPr& E1 = EdgeSet[keyId1];
const TIntPr& E2 = EdgeSet[keyId2];
TIntPr NewE1(E1.Val1, E2.Val2), NewE2(E2.Val1, E1.Val2);
if (NewE1!=NewE2 && NewE1.Val1!=NewE1.Val2 && NewE2.Val1!=NewE2.Val2 && ! EdgeSet.IsKey(NewE1) && ! EdgeSet.IsKey(NewE2)) {
EdgeSet.DelKeyId(keyId1); EdgeSet.DelKeyId(keyId2);
EdgeSet.AddKey(TIntPr(NewE1));
EdgeSet.AddKey(TIntPr(NewE2));
} else { skip++; }
if (swps % Edges == 0) {
printf("\r %uk/%uk: %uk skip [%s]", swps/1000u, 2*uint(Edges)*uint(NSwitch)/1000u, skip/1000u, ExeTm.GetStr());
if (ExeTm.GetSecs() > 2*3600) { printf(" *** Time limit!\n"); break; } // time limit 2 hours
}
}
printf("\r total %uk switchings attempted, %uk skiped [%s]\n", 2*uint(Edges)*uint(NSwitch)/1000u, skip/1000u, ExeTm.GetStr());
for (int e = 0; e < EdgeSet.Len(); e++) {
Graph.AddEdge(EdgeSet[e].Val1, EdgeSet[e].Val2); }
return GraphPt;
}
示例9: AddNodes
TFfGGen::TStopReason TUndirFFire::AddNodes(const int& GraphNodes, const bool& FloodStop) {
printf("\n***Undirected GEO ForestFire: graph(%d,%d) add %d nodes, burn prob %.3f\n",
Graph->GetNodes(), Graph->GetEdges(), GraphNodes, BurnProb);
TExeTm ExeTm;
int Burned1 = 0, Burned2 = 0, Burned3 = 0; // last 3 fire sizes
TIntPrV NodesEdgesV;
// create initial set of nodes
if (Graph.Empty()) { Graph = PUNGraph::New(); }
if (Graph->GetNodes() == 0) { Graph->AddNode(); }
int NEdges = Graph->GetEdges();
// forest fire
for (int NNodes = Graph->GetNodes() + 1; NNodes <= GraphNodes; NNodes++) {
const int NewNId = Graph->AddNode(-1);
IAssert(NewNId == Graph->GetNodes() - 1); // node ids have to be 0...N
const int StartNId = Rnd.GetUniDevInt(NewNId);
const int NBurned = BurnGeoFire(StartNId);
// add edges to burned nodes
for (int e = 0; e < NBurned; e++) {
Graph->AddEdge(NewNId, GetBurnedNId(e));
}
NEdges += NBurned;
Burned1 = Burned2; Burned2 = Burned3; Burned3 = NBurned;
if (NNodes % Kilo(1) == 0) {
printf("(%d, %d) burned: [%d,%d,%d] [%s]\n", NNodes, NEdges, Burned1, Burned2, Burned3, ExeTm.GetStr());
NodesEdgesV.Add(TIntPr(NNodes, NEdges));
}
if (FloodStop && NEdges>1000 && NEdges / double(NNodes)>100.0) { // average node degree is more than 50
printf("!!! FLOOD. G(%6d, %6d)\n", NNodes, NEdges); return TFfGGen::srFlood;
}
}
printf("\n");
IAssert(Graph->GetEdges() == NEdges);
return TFfGGen::srOk;
}