本文整理汇总了C++中TIntV类的典型用法代码示例。如果您正苦于以下问题:C++ TIntV类的具体用法?C++ TIntV怎么用?C++ TIntV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIntV类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
LogOutput Log;
THash<TStr, TStr> Arguments;
ArgumentParser::ParseArguments(argc, argv, Arguments, Log);
TStr StartString = ArgumentParser::GetArgument(Arguments, "start", "2009-01-14");
TStr EndString = ArgumentParser::GetArgument(Arguments, "end", "2012-09-30");
TStr QBDBCDirectory = ArgumentParser::GetArgument(Arguments, "qbdbc", "/lfs/1/tmp/curis/QBDBC-final/");
TStr QBDBDirectory = ArgumentParser::GetArgument(Arguments, "qbdb", "/lfs/1/tmp/curis/QBDB/");
TSecTm StartDate = TSecTm::GetDtTmFromYmdHmsStr(StartString);
TSecTm EndDate = TSecTm::GetDtTmFromYmdHmsStr(EndString);
TQuoteBase QB;
TDocBase DB;
TClusterBase CB;
PNGraph QGraph;
TQuoteBase NewQB;
TDocBase NewDB;
TSecTm CurrentDate = StartDate;
TInt NumUnprocessedQuotes = 0;
TInt NumUnprocessedDocs = 0;
TInt NumQuotes = 0;
TInt NumClusters = 0;
TInt NumTopClusters = 0;
TInt NumDiscardedClustersByPeak = 0;
TInt NumDiscardedClustersByVariant = 0;
TInt NumRemainingClusters = 0;
TInt NumVariants = 0;
TInt NumDocs = 0;
TInt Count = 0;
while(CurrentDate < EndDate) {
if (Count % 100 == 0) Err("%d days evaluated!\n", Count.Val);
TDataLoader::LoadCumulative(QBDBCDirectory, CurrentDate.GetDtYmdStr(), QB, DB, CB, QGraph);
TDataLoader::LoadQBDB(QBDBDirectory, CurrentDate.GetDtYmdStr(), NewQB, NewDB);
if (NewQB.Len() > 0) {
NumUnprocessedQuotes += NewQB.Len();
NumUnprocessedDocs += NewDB.Len();
}
if (QB.Len() > 0) {
Count++;
Err("Loaded base for %s! Calculating stats...\n", CurrentDate.GetDtYmdStr().CStr());
NumQuotes += QB.Len();
NumClusters += CB.Len();
NumDocs += DB.Len();
TIntV TopClusters;
CB.GetTopClusterIdsByFreq(TopClusters);
int NmTopClusters = TopClusters.Len();
NumTopClusters += NmTopClusters;
for (int i = 0; i < NmTopClusters; i++) {
TCluster C;
CB.GetCluster(TopClusters[i], C);
if (C.GetDiscardState() == 1) {
NumDiscardedClustersByPeak++;
} else if (C.GetDiscardState() == 2) {
NumDiscardedClustersByVariant++;
} else {
NumRemainingClusters++;
NumVariants += C.GetNumUniqueQuotes();
}
}
}
CurrentDate.AddDays(1);
}
Err("Number of quotes processed through in total: %d\n", NumUnprocessedQuotes.Val);
Err("Number of docs processed through in total: %d\n", NumUnprocessedDocs.Val);
Err("Number of quotes in total: %d\n", NumQuotes.Val);
Err("Number of clusters in total: %d\n", NumClusters.Val);
Err("Number of docs in total: %d\n", NumDocs.Val);
Err("Number of top clusters in total: %d\n", NumTopClusters.Val);
Err("Number of discarded clusters by peak in total: %d\n", NumDiscardedClustersByPeak.Val);
Err("Number of discarded clusters by variant total: %d\n", NumDiscardedClustersByVariant.Val);
Err("Number of top clusters remaining in total: %d\n", NumRemainingClusters.Val);
Err("Number of top variants found: %d\n", NumVariants.Val);
Err("=============\n===========\n");
Err("Number of days: %d\n", Count.Val);
double AvgQuotes = (NumQuotes.Val * 1.0 / Count.Val);
double AvgClusters = (NumClusters.Val * 1.0 / Count.Val);
double AvgDocs = (NumDocs.Val * 1.0 / Count.Val);
double AvgTopClusters = (NumTopClusters.Val * 1.0 / Count.Val);
double AvgDiscardedPeaks = (NumDiscardedClustersByPeak.Val * 1.0 / Count.Val);
double AvgDiscardedVariants = (NumDiscardedClustersByVariant.Val * 1.0 / Count.Val);
double AvgRemaining = (NumRemainingClusters.Val * 1.0 / Count.Val);
double AvgNumVariants = (NumVariants.Val * 1.0 / Count.Val);
Err("Average number of quotes in total: %f\n", AvgQuotes);
Err("Average number of clusters in total: %f\n", AvgClusters);
Err("Average number of docs in total: %f\n", AvgDocs);
Err("Average number of top clusters in total: %f\n", AvgTopClusters);
Err("Average number of discarded clusters by peak in total: %f\n", AvgDiscardedPeaks);
Err("Average number of discarded clusters by variant total: %f\n", AvgDiscardedVariants);
Err("Average number of top clusters remaining in total: %f\n", AvgRemaining);
Err("Average number of top variants found: %f\n", AvgNumVariants);
return 0;
}
开发者ID:snap-stanford,项目名称:curis-2012,代码行数:100,代码来源:printstatistics.cpp
示例2: main
int main(int argc, char* argv[]) {
TTableContext Context;
Schema NetworkS;
NetworkS.Add(TPair<TStr, TAttrType>("Year", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("Month", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("DayOfMonth", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("DayOfWeek", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("DepTime", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("CRSDepTime", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("ArrTime", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("CRSArrTime", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("UniqueCarrier", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("FlightNum", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("TailNum", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("ActualElapsedTime", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("CRSElapsedTime", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("AirTime", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("ArrDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("DepDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("Origin", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("Dest", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("Distance", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("TaxiIn", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("TaxiOut", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("Cancelled", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("CancellationCode", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("Diverted", atStr));
NetworkS.Add(TPair<TStr, TAttrType>("CarrierDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("WeatherDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("NASDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("SecurityDelay", atInt));
NetworkS.Add(TPair<TStr, TAttrType>("LateAircraftDelay", atInt));
TIntV RelevantCols;
RelevantCols.Add(0); RelevantCols.Add(1); RelevantCols.Add(2);RelevantCols.Add(3); RelevantCols.Add(4); RelevantCols.Add(5);
RelevantCols.Add(6); RelevantCols.Add(7); RelevantCols.Add(8); RelevantCols.Add(9); RelevantCols.Add(10); RelevantCols.Add(11);
RelevantCols.Add(12); RelevantCols.Add(13); RelevantCols.Add(14); RelevantCols.Add(15); RelevantCols.Add(16); RelevantCols.Add(17);
RelevantCols.Add(18); RelevantCols.Add(19); RelevantCols.Add(20); RelevantCols.Add(21); RelevantCols.Add(22); RelevantCols.Add(23);
RelevantCols.Add(24); RelevantCols.Add(25); RelevantCols.Add(26); RelevantCols.Add(27); RelevantCols.Add(28);
PTable P = TTable::LoadSS(NetworkS, "table/2007.csv",
Context, RelevantCols, ',', false);
TStrV SV;
TStrV DV;
TStrV VE;
double start = omp_get_wtime();
PNSparseNet G = TSnap::ToNetwork<PNSparseNet>(P, TStr("Origin"),
TStr("Dest"), SV, DV, VE, aaLast);
double end = omp_get_wtime();
printf("Conversion time without attributes %f\n", (end-start));
start = omp_get_wtime();
TSnap::AddAttrTable<PNSparseNet>(P, G, TStr("Origin"),
TStr("Dest"), SV, DV, VE, aaLast);
end = omp_get_wtime();
printf("Conversion time with attributes %f\n", (end-start));
/*(PTable Table, PGraph& Graph, const TStr& SrcCol, const TStr& DstCol,
TStrV& SrcAttrV, TStrV& DstAttrV, TStrV& EdgeAttrV, TAttrAggr AggrPolicy, TInt DefaultInt,
TFlt DefaultFlt, TStr DefaultStr)*/
}
开发者ID:sramas15,项目名称:snapr,代码行数:61,代码来源:benchmark-sparse-tonetwork.cpp
示例3: WIdQV
void TNGramBs::GetNGramIdV(
const TStr& HtmlStr, TIntV& NGramIdV, TIntPrV& NGramBEChXPrV) const {
// create MxNGramLen queues
TVec<TIntQ> WIdQV(MxNGramLen);
TVec<TIntPrQ> BEChXPrQV(MxNGramLen);
for (int NGramLen=1; NGramLen<MxNGramLen; NGramLen++){
WIdQV[NGramLen].Gen(100*NGramLen, NGramLen+1);
BEChXPrQV[NGramLen].Gen(100*NGramLen, NGramLen+1);
}
bool AllWIdQClrP=true;
// extract words from text-string
PSIn HtmlSIn=TStrIn::New(HtmlStr, false);
THtmlLx HtmlLx(HtmlSIn);
while (HtmlLx.Sym!=hsyEof){
if ((HtmlLx.Sym==hsyStr)||(HtmlLx.Sym==hsyNum)){
// get word-string & word-id
TStr WordStr=HtmlLx.UcChA;
int WId; int SymBChX=HtmlLx.SymBChX; int SymEChX=HtmlLx.SymEChX;
if ((SwSet.Empty())||(!SwSet->IsIn(WordStr))){
if (!Stemmer.Empty()){
WordStr=Stemmer->GetStem(WordStr);}
if (IsWord(WordStr, WId)){
if (!IsSkipWord(WId)){
NGramIdV.Add(0+WId); // add single word
NGramBEChXPrV.Add(TIntPr(SymBChX, SymEChX)); // add positions
for (int NGramLen=1; NGramLen<MxNGramLen; NGramLen++){
TIntQ& WIdQ=WIdQV[NGramLen];
TIntPrQ& BEChXPrQ=BEChXPrQV[NGramLen];
WIdQ.Push(WId); BEChXPrQ.Push(TIntPr(SymBChX, SymEChX));
AllWIdQClrP=false;
// if queue full
if (WIdQ.Len()==NGramLen+1){
// create sequence
TIntV WIdV; WIdQ.GetSubValVec(0, WIdQ.Len()-1, WIdV);
TIntPrV BEChXPrV; BEChXPrQ.GetSubValVec(0, BEChXPrQ.Len()-1, BEChXPrV);
// add ngram-id or reset queues
int WIdVP;
if (WIdVToFqH.IsKey(WIdV, WIdVP)){ // if sequence is frequent
int NGramId=GetWords()+WIdVP; // get sequence ngram-id
NGramIdV.Add(NGramId); // add sequence ngram-id
NGramBEChXPrV.Add(TIntPr(BEChXPrV[0].Val1, BEChXPrV.Last().Val2)); // add positions
}
}
}
}
} else {
// break queue sequences if infrequent word occures
if (!AllWIdQClrP){
for (int NGramLen=1; NGramLen<MxNGramLen; NGramLen++){
TIntQ& WIdQ=WIdQV[NGramLen];
TIntPrQ& BEChXPrQ=BEChXPrQV[NGramLen];
if (!WIdQ.Empty()){WIdQ.Clr(); BEChXPrQ.Clr();}
}
AllWIdQClrP=true;
}
}
}
}
// get next symbol
HtmlLx.GetSym();
}
}
开发者ID:bergloman,项目名称:qminer,代码行数:62,代码来源:phrase.cpp
示例4: GetEIdV
void TNEANet::GetEIdV(TIntV& EIdV) const {
EIdV.Gen(GetEdges(), 0);
for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
EIdV.Add(EdgeH.GetKey(E));
}
}
开发者ID:Daron-Wan,项目名称:snap,代码行数:6,代码来源:network.cpp
示例5: IAssert
/////////////////////////////////////////////////
// BLEU-score
double TEvalScoreBleu::Eval(const PTransCorpus& TransCorpus, const TIntV& _SentIdV) {
// check if the corpus has translations
IAssert(TransCorpus->IsTrans());
// ngram counts (cliped and full)
TIntH ClipCountNGramH, CountNGramH;
// candidate and effective reference length
int FullTransLen = 0, FullRefLen = 0;
// iterate over sentences
TIntV SentIdV = _SentIdV;
if (SentIdV.Empty()) { TransCorpus->GetSentIdV(SentIdV); }
const int Sents = SentIdV.Len();
for (int SentIdN = 0; SentIdN < Sents; SentIdN++) {
const int SentId = SentIdV[SentIdN];
// tokenize translation
TIntV TransWIdV; Parse(TransCorpus->GetTransStr(SentId), TransWIdV);
TIntH TransNGramH; GetNGramH(TransWIdV, MxNGramLen, TransNGramH);
TIntH FreeTransNGramH = TransNGramH; // number of non-matched ngrams
// counters for getting the closest length of reference sentences
const int TransLen = TransWIdV.Len();
int BestLen = 0, BestLenDiff = TInt::Mx;
// go over reference translations and count ngram matches
TStrV RefTransStrV = TransCorpus->GetRefTransStrV(SentId);
for (int RefN = 0; RefN < RefTransStrV.Len(); RefN++) {
// parse reference translation sentence
TIntV RefWIdV; Parse(RefTransStrV[RefN], RefWIdV);
TIntH RefNGramH; GetNGramH(RefWIdV, MxNGramLen, RefNGramH);
// check for matches
int TransNGramKeyId = TransNGramH.FFirstKeyId();
while(TransNGramH.FNextKeyId(TransNGramKeyId)) {
const int NGramId = TransNGramH.GetKey(TransNGramKeyId);
const int FreeTransNGrams = FreeTransNGramH(NGramId);
if (RefNGramH.IsKey(NGramId) && (FreeTransNGrams>0)) {
// ngram match and still some free ngrams left to clip
const int RefNGrams = RefNGramH(NGramId);
FreeTransNGramH(NGramId) = TInt::GetMx(0, FreeTransNGrams - RefNGrams);
}
}
// check the length difference
const int RefLen = RefWIdV.Len();
const int LenDiff = TInt::Abs(TransLen - RefLen);
if (LenDiff < BestLenDiff) {
BestLen = RefLen; BestLenDiff = LenDiff;
}
}
// count ngrams
int TransNGramKeyId = TransNGramH.FFirstKeyId();
while(TransNGramH.FNextKeyId(TransNGramKeyId)) {
// get ngram
const int NGramId = TransNGramH.GetKey(TransNGramKeyId);
IAssert(NGramId != -1);
// check if two hash tables are aligned (should be...)
const int FreeNGramId = FreeTransNGramH.GetKey(TransNGramKeyId);
IAssert(NGramId == FreeNGramId);
// get ngram count and clip-count
const int Count = TransNGramH[TransNGramKeyId];
const int ClipCount = Count - FreeTransNGramH[TransNGramKeyId];
// add ngram to the coprus ngram counts
CountNGramH.AddDat(NGramId) += Count;
ClipCountNGramH.AddDat(NGramId) += ClipCount;
}
// count length
FullTransLen += TransLen;
FullRefLen += BestLen;
}
// calcualte ngram precisions
TIntV ClipCountV(MxNGramLen); ClipCountV.PutAll(0);
int ClipCountKeyId = ClipCountNGramH.FFirstKeyId();
while (ClipCountNGramH.FNextKeyId(ClipCountKeyId)) {
const int NGramId = ClipCountNGramH.GetKey(ClipCountKeyId);
const int NGramLen = GetNGramLen(NGramId);
IAssert(0 < NGramLen && NGramLen <= MxNGramLen);
ClipCountV[NGramLen-1] += ClipCountNGramH[ClipCountKeyId];
}
TIntV CountV(MxNGramLen); CountV.PutAll(0);
int CountKeyId = CountNGramH.FFirstKeyId();
while (CountNGramH.FNextKeyId(CountKeyId)) {
const int NGramId = CountNGramH.GetKey(CountKeyId);
const int NGramLen = GetNGramLen(NGramId);
IAssert(0 < NGramLen && NGramLen <= MxNGramLen);
CountV[NGramLen-1] += CountNGramH[CountKeyId];
}
TFltV PrecV(MxNGramLen, 0);
for (int NGramLen = 0; NGramLen < MxNGramLen; NGramLen++) {
const int ClipCount = ClipCountV[NGramLen];
const int Count = CountV[NGramLen];
const double Prec = (Count > 0) ? double(ClipCount)/double(Count) : 0.0;
PrecV.Add(Prec);
//printf("%d-gram Match:%d Total:%d Prec:%.5f\n", NGramLen+1, ClipCount, Count, Prec);
}
// calcualte brevity penalty
double LogBP = TFlt::GetMn(0.0, 1.0 - double(FullRefLen)/double(FullTransLen));
double BP = exp(LogBP);
// calculate full BLEU score
//.........这里部分代码省略.........
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:101,代码来源:biling.cpp
示例6: GetWIdVStr
/////////////////////////////////////////////////
// NGram-Base
TStr TNGramBs::GetWIdVStr(const TIntV& WIdV) const {
TChA ChA;
for (int WIdN=0; WIdN<WIdV.Len(); WIdN++){
if (WIdN>0){ChA+=' '/*'_'*/;} ChA+=GetWordStr(WIdV[WIdN]);}
return ChA;
}
开发者ID:bergloman,项目名称:qminer,代码行数:8,代码来源:phrase.cpp
示例7: DemoFullBfsDfs
void DemoFullBfsDfs() {
const int NNodes = 500;
PGraph G = GenFull<PGraph>(NNodes);
PNGraph GOut;
int TreeSz, TreeDepth;
// Get BFS tree from first node without following links (demos different options)
GOut = GetBfsTree(G, 1, false, false);
GetSubTreeSz(G, 1, false, false, TreeSz, TreeDepth);
printf("FollowOut=false, FollowIn=false, GOut->GetNodes() == %d, GOut->GetEdges() = %d\n",
GOut->GetNodes(), G->GetEdges());
printf("TreeSz == %d, TreeDepth = %d\n", TreeSz, TreeDepth);
GOut = GetBfsTree(G, NNodes-1, true, true);
GetSubTreeSz(G, 1, true, true, TreeSz, TreeDepth);
printf("FollowOut=true, FollowIn=true, GOut->GetNodes() == %d, GOut->GetEdges() = %d\n",
GOut->GetNodes(), G->GetEdges());
printf("TreeSz == %d, TreeDepth = %d\n", TreeSz, TreeDepth);
GOut = GetBfsTree(G, NNodes/2, true, false);
GetSubTreeSz(G, 1, true, false, TreeSz, TreeDepth);
printf("FollowOut=true, FollowIn=false, GOut->GetNodes() == %d, GOut->GetEdges() = %d\n",
GOut->GetNodes(), G->GetEdges());
printf("TreeSz == %d, TreeDepth = %d\n", TreeSz, TreeDepth);
GOut = GetBfsTree(G, 1, false, true);
GetSubTreeSz(G, 1, false, true, TreeSz, TreeDepth);
printf("FollowOut=false, FollowIn=true, GOut->GetNodes() == %d, GOut->GetEdges() = %d\n",
GOut->GetNodes(), G->GetEdges());
printf("TreeSz == %d, TreeDepth = %d\n", TreeSz, TreeDepth);
TIntV NIdV;
int StartNId, Hop, Nodes;
StartNId = 1;
Hop = 1;
Nodes = GetNodesAtHop(G, StartNId, Hop, NIdV, HasGraphFlag(typename PGraph::TObj, gfDirected));
printf("StartNId = %d, Nodes = %d, GetNodesAtHop NIdV.Len() = %d\n", StartNId, Nodes, NIdV.Len());
TIntPrV HopCntV;
Nodes = GetNodesAtHops(G, StartNId, HopCntV, HasGraphFlag(typename PGraph::TObj, gfDirected));
printf("StartNId = %d, Nodes = %d, GetNodesAtHops HopCntV.Len() = %d\n", StartNId, Nodes, HopCntV.Len());
int Length, SrcNId, DstNId;
SrcNId = 1;
DstNId = NNodes-1;
Length = GetShortPath(G, SrcNId, DstNId, HasGraphFlag(typename PGraph::TObj, gfDirected));
printf("SPL Length = %d\n", Length);
TIntH NIdToDistH;
int MaxDist = 9;
Length = GetShortPath(G, SrcNId, NIdToDistH, HasGraphFlag(typename PGraph::TObj, gfDirected), MaxDist);
// for (int i = 0; i < min(5,NIdToDistH.Len()); i++) {
// printf("NIdToDistH[%d] = %d\n", i, NIdToDistH[i].Val);
// }
int FullDiam;
double EffDiam, AvgDiam;
int NTestNodes = 10;
for (int IsDir = 0; IsDir < 2; IsDir++) {
printf("IsDir = %d:\n", IsDir);
FullDiam = GetBfsFullDiam(G, NTestNodes, IsDir);
printf("FullDiam = %d\n", FullDiam);
EffDiam = GetBfsEffDiam (G, NTestNodes, IsDir);
printf("EffDiam = %.3f\n", EffDiam);
EffDiam = GetBfsEffDiam (G, NTestNodes, IsDir, EffDiam, FullDiam);
printf("EffDiam = %.3f, FullDiam = %d\n", EffDiam, FullDiam);
EffDiam = GetBfsEffDiam (G, NTestNodes, IsDir, EffDiam, FullDiam, AvgDiam);
printf("EffDiam = %.3f, FullDiam = %d, AvgDiam = %.3f\n", EffDiam, FullDiam, AvgDiam);
TIntV SubGraphNIdV;
for (int i = 0; i < NTestNodes; i++) {
SubGraphNIdV.Add(G->GetRndNId());
}
// for (int i = 0; i < SubGraphNIdV.Len(); i++) {
// printf("SubGraphNIdV[%d] = %d\n", i, SubGraphNIdV[i].Val);
// }
EffDiam = GetBfsEffDiam(G, NTestNodes, SubGraphNIdV, IsDir, EffDiam, FullDiam);
printf("For subgraph: EffDiam = %.3f, FullDiam = %d\n", EffDiam, FullDiam);
}
}
开发者ID:Accio,项目名称:snap,代码行数:92,代码来源:demo-bfsdfs.cpp
示例8: DemoBFSUndirectedRandom
// Demos BFS functions on undirected graph that is not fully connected
void DemoBFSUndirectedRandom() {
PUNGraph G;
TStr FName = TStr::Fmt("%s/sample_bfsdfs_unpower.txt", DIRNAME);
const int NNodes = 50;
G = GenRndPowerLaw(NNodes, 2.5);
// Can save/here
// SaveEdgeList(G, FName);
// G = LoadEdgeList<PUNGraph>(FName);
TIntStrH NodeLabelH;
for (int i = 0; i < G->GetNodes(); i++) {
NodeLabelH.AddDat(i, TStr::Fmt("%d", i));
}
DrawGViz(G, gvlNeato, TStr::Fmt("%s/sample_bfsdfs_unpower.png", DIRNAME), "Sample bfsdfs Graph", NodeLabelH);
TIntV NIdV;
int StartNId, Hop, Nodes;
int IsDir = 0;
printf("IsDir = %d:\n", IsDir);
StartNId = 1;
Hop = 1;
Nodes = GetNodesAtHop(G, StartNId, Hop, NIdV, IsDir);
printf("StartNId = %d, Nodes = %d, GetNodesAtHop NIdV.Len() = %d, NIdV[0] = %d\n", StartNId, Nodes, NIdV.Len(), NIdV[0].Val);
TIntPrV HopCntV;
Nodes = GetNodesAtHops(G, StartNId, HopCntV, IsDir);
printf("StartNId = %d, Nodes = %d, GetNodesAtHops HopCntV.Len() = %d\n", StartNId , Nodes, HopCntV.Len());
// for (int N = 0; N < HopCntV.Len(); N++) {
// printf("HopCntV[%d] = (%d, %d)\n", N, HopCntV[N].Val1.Val, HopCntV[N].Val2.Val);
// }
int Length, SrcNId, DstNId;
SrcNId = 1;
DstNId = G->GetNodes() - 1;
Length = GetShortPath(G, SrcNId, DstNId, IsDir);
printf("%d -> %d: SPL Length = %d\n", SrcNId, DstNId, Length);
SrcNId = 1;
DstNId = 33;
Length = GetShortPath(G, SrcNId, DstNId, IsDir);
printf("%d -> %d: SPL Length = %d\n", SrcNId, DstNId, Length);
TIntH NIdToDistH;
int MaxDist = 9;
Length = GetShortPath(G, SrcNId, NIdToDistH, IsDir, MaxDist);
// for (int i = 0; i < min(5,NIdToDistH.Len()); i++) {
// printf("NIdToDistH[%d] = %d\n", i, NIdToDistH[i].Val);
// }
TInt::Rnd.PutSeed(0);
int FullDiam;
double EffDiam, AvgSPL;
int NTestNodes = G->GetNodes() / 3 * 2;
FullDiam = GetBfsFullDiam(G, NTestNodes, IsDir);
printf("FullDiam = %d\n", FullDiam);
EffDiam = GetBfsEffDiam(G, NTestNodes, IsDir);
printf("EffDiam = %.3f\n", EffDiam);
EffDiam = GetBfsEffDiam(G, NTestNodes, IsDir, EffDiam, FullDiam);
printf("EffDiam = %.3f, FullDiam = %d\n", EffDiam, FullDiam);
EffDiam = GetBfsEffDiam(G, NTestNodes, IsDir, EffDiam, FullDiam, AvgSPL);
printf("EffDiam = %.3f, FullDiam = %d, AvgDiam = %.3f\n", EffDiam, FullDiam, AvgSPL);
TIntV SubGraphNIdV;
SubGraphNIdV.Add(0);
SubGraphNIdV.Add(4);
SubGraphNIdV.Add(31);
SubGraphNIdV.Add(45);
SubGraphNIdV.Add(18);
SubGraphNIdV.Add(11);
SubGraphNIdV.Add(11);
SubGraphNIdV.Add(48);
SubGraphNIdV.Add(34);
SubGraphNIdV.Add(30);
EffDiam = GetBfsEffDiam(G, NTestNodes, SubGraphNIdV, IsDir, EffDiam, FullDiam);
printf("For subgraph: EffDiam = %.4f, FullDiam = %d\n", EffDiam, FullDiam);
}
开发者ID:Accio,项目名称:snap,代码行数:92,代码来源:demo-bfsdfs.cpp
示例9: DemoBFSDirectedRandom
// Demos BFS functions on directed graph that is not fully connected
void DemoBFSDirectedRandom() {
PNGraph G = TNGraph::New();
TStr FName = TStr::Fmt("%s/sample_bfsdfs_ngraph.txt", DIRNAME);
// Create benchmark graph, initially visually to confirm values are correct
const int NNodes = 30;
G = GenRndGnm<PNGraph>(NNodes, NNodes*2);
// Add some more random edges
for (int i = 0; i < 10; i++) {
TInt Src, Dst;
do {
Src = G->GetRndNId();
Dst = G->GetRndNId();
}
while (Src == Dst || G->IsEdge(Src, Dst));
G->AddEdge(Src, Dst);
}
// Add isolated component
G->AddNode(NNodes);
G->AddNode(NNodes+1);
G->AddNode(NNodes+2);
G->AddEdge(NNodes, NNodes+1);
G->AddEdge(NNodes+1, NNodes+2);
G->AddEdge(NNodes+2, NNodes+1);
printf("G->GetNodes() = %d, G->GetEdges() = %d\n", G->GetNodes(), G->GetEdges());
// SaveEdgeList(G, FName);
// G = LoadEdgeList<PNGraph>(FName);
TIntStrH NodeLabelH;
for (int i = 0; i < G->GetNodes(); i++) {
NodeLabelH.AddDat(i, TStr::Fmt("%d", i));
}
DrawGViz(G, gvlDot, TStr::Fmt("%s/sample_bfsdfs_ngraph.png", DIRNAME), "Sample BFS Graph", NodeLabelH);
printf("G->GetNodes() = %d, G->GetEdges() = %d\n", G->GetNodes(), G->GetEdges());
TIntV NIdV;
int StartNId, Hop, Nodes;
// for (int IsDir = 0; IsDir < 2; IsDir++) {
int IsDir = 1;
printf("IsDir = %d:\n", IsDir);
StartNId = 11;
Hop = 1;
Nodes = GetNodesAtHop(G, StartNId, Hop, NIdV, IsDir);
printf("Nodes = %d, GetNodesAtHop NIdV.Len() = %d\n", Nodes, NIdV.Len());
for (int i = 0; i < NIdV.Len(); i++) {
printf("NIdV[%d] = %d\n", i, NIdV[i].Val);
}
printf("Nodes == 2");
printf("NIdV.Len() == 2");
TIntPrV HopCntV;
Nodes = GetNodesAtHops(G, StartNId, HopCntV, IsDir);
printf("Nodes = %d, GetNodesAtHops HopCntV.Len() = %d\n", Nodes, HopCntV.Len());
printf("Nodes == 10");
printf("HopCntV.Len() == 10");
// for (int N = 0; N < HopCntV.Len(); N++) {
// printf("HopCntV[%d] = (%d, %d)\n", N, HopCntV[N].Val1.Val, HopCntV[N].Val2.Val);
// }
int Length, SrcNId, DstNId;
SrcNId = 11;
DstNId = G->GetNodes() - 1;
Length = GetShortPath(G, SrcNId, DstNId, IsDir);
printf("%d -> %d: SPL Length = %d\n", SrcNId, DstNId, Length);
SrcNId = 11;
DstNId = 27;
Length = GetShortPath(G, SrcNId, DstNId, IsDir);
printf("%d -> %d: SPL Length = %d\n", SrcNId, DstNId, Length);
TIntH NIdToDistH;
int MaxDist = 9;
Length = GetShortPath(G, SrcNId, NIdToDistH, IsDir, MaxDist);
// for (int i = 0; i < min(5,NIdToDistH.Len()); i++) {
// printf("NIdToDistH[%d] = %d\n", i, NIdToDistH[i].Val);
// }
TInt::Rnd.PutSeed(0);
int FullDiam;
double EffDiam, AvgSPL;
int NTestNodes = G->GetNodes() / 2;
FullDiam = GetBfsFullDiam(G, NTestNodes, IsDir);
printf("FullDiam = %d\n", FullDiam);
EffDiam = GetBfsEffDiam(G, NTestNodes, IsDir);
printf("EffDiam = %.3f\n", EffDiam);
EffDiam = GetBfsEffDiam(G, NTestNodes, IsDir, EffDiam, FullDiam);
//.........这里部分代码省略.........
开发者ID:Accio,项目名称:snap,代码行数:101,代码来源:demo-bfsdfs.cpp
示例10: GenFFreeBlobPtV
void TBlobBs::GenFFreeBlobPtV(const TIntV& BlockLenV, TBlobPtV& FFreeBlobPtV){
FFreeBlobPtV.Gen(BlockLenV.Len()+1);
}
开发者ID:adobekan,项目名称:qminer,代码行数:3,代码来源:blobbs.cpp
示例11: ManipulateMMNet
// Create TMMNet, add modes, crossnets, create subgraphs, covert to TNEANet
void ManipulateMMNet() {
int NNodes = 1000;
int NEdges = 1000;
// Create a multimodal network
PMMNet Graph;
Graph = PMMNet::New();
PrintMMNetStats("Empty MMNet",Graph);
// Add mode
TStr TestMode1("TestMode1");
Graph->AddModeNet(TestMode1);
TInt TestModeId1 = Graph->GetModeId(TestMode1);
// Add same-mode crossnet, directed
TStr TestCross1("TestCross1");
Graph->AddCrossNet(TestMode1, TestMode1, TestCross1, true);
TInt TestCrossId1 = Graph->GetCrossId(TestCross1);
// Add same-mode crossnet, undirected
TStr TestCross2("TestCross2");
Graph->AddCrossNet(TestModeId1, TestModeId1, TestCross2, false);
TInt TestCrossId2 = Graph->GetCrossId(TestCross2);
// Add mode
TStr TestMode2("TestMode2");
Graph->AddModeNet(TestMode2);
TInt TestModeId2 = Graph->GetModeId(TestMode2);
// Add crossnet, directed
TStr TestCross3("TestCross3");
Graph->AddCrossNet(TestMode1, TestMode2, TestCross3, true);
TInt TestCrossId3 = Graph->GetCrossId(TestCross3);
// Add crossnet, undirected
TStr TestCross4("TestCross4");
Graph->AddCrossNet(TestModeId1, TestModeId2, TestCross4, false);
TInt TestCrossId4 = Graph->GetCrossId(TestCross4);
PrintMMNetStats("MMNet with modes/crossnets",Graph);
// Add Nodes
TModeNet& ModeNet1 = Graph->GetModeNetByName(TestMode1);
TModeNet& ModeNet2 = Graph->GetModeNetById(TestModeId2);
for (int i=0; i < NNodes; i++) {
ModeNet1.AddNode(i);
ModeNet2.AddNode(i*2);
}
// Add edges
TCrossNet& CrossNet1 = Graph->GetCrossNetByName(TestCross1);
TCrossNet& CrossNet2 = Graph->GetCrossNetById(TestCrossId2);
TCrossNet& CrossNet3 = Graph->GetCrossNetByName(TestCross3);
TCrossNet& CrossNet4 = Graph->GetCrossNetById(TestCrossId4);
for (int i=0; i < NEdges; i++) {
CrossNet1.AddEdge(i, (i+1)%NNodes, i);
CrossNet2.AddEdge((i+5)%NNodes, i, i);
CrossNet3.AddEdge(i, (i%NNodes)*2, i);
CrossNet4.AddEdge((i+5)%NNodes, (i%NNodes)*2, i);
}
//Iterate over modes
for (TMMNet::TModeNetI MI = Graph->BegModeNetI(); MI < Graph->EndModeNetI(); MI++) {
PrintGStats(MI.GetModeName().GetCStr(), MI.GetModeNet());
}
//Iterate over crossnets
for (TMMNet::TCrossNetI CI = Graph->BegCrossNetI(); CI < Graph->EndCrossNetI(); CI++) {
PrintGStats(CI.GetCrossName().GetCStr(), CI.GetCrossNet());
}
// Get subgraph
TStrV CrossNets;
CrossNets.Add(TestCross1);
PMMNet Subgraph = Graph->GetSubgraphByCrossNet(CrossNets);
PrintMMNetStats("Subgraph", Subgraph);
TModeNet& M1 = Subgraph->GetModeNetByName(TestMode1);
PrintGStats("M1", M1);
// Get neighbor types
TStrV M1Names;
M1.GetCrossNetNames(M1Names);
printf("Num neighbor types %d\n", M1Names.Len());
// Get Neighbors for node 0
TIntV Neighbors;
M1.GetNeighborsByCrossNet(0, TestCross1, Neighbors);
printf("Num Neighbors %d\n", Neighbors.Len());
// Convert to TNEANet
TIntV CrossNetIds;
CrossNetIds.Add(TestCrossId1);
CrossNetIds.Add(TestCrossId2);
CrossNetIds.Add(TestCrossId3);
CrossNetIds.Add(TestCrossId4);
TVec<TTriple<TInt, TStr, TStr> > NodeAttrMapping; //Triples of (ModeId, OldAttrName, NewAttrName)
TVec<TTriple<TInt, TStr, TStr> > EdgeAttrMapping; //Triples of (CrossId, OldAttrName, NewAttrName)
PNEANet Net = Graph->ToNetwork(CrossNetIds, NodeAttrMapping, EdgeAttrMapping);
PrintGStats("TNEANet", Net);
}
开发者ID:JohnMatta,项目名称:snap,代码行数:98,代码来源:demo-multimodal.cpp
示例12: NewCmtyVH
/// rewire bipartite community affiliation graphs
void TAGMUtil::RewireCmtyNID(THash<TInt,TIntV >& CmtyVH, TRnd& Rnd) {
THash<TInt,TIntV > NewCmtyVH(CmtyVH.Len());
TIntV NDegV;
TIntV CDegV;
for (int i = 0; i < CmtyVH.Len(); i++) {
int CID = CmtyVH.GetKey(i);
for (int j = 0; j < CmtyVH[i].Len(); j++) {
int NID = CmtyVH[i][j];
NDegV.Add(NID);
CDegV.Add(CID);
}
}
TIntPrSet CNIDSet(CDegV.Len());
int c=0;
while (c++ < 15 && CDegV.Len() > 1) {
for (int i = 0; i < CDegV.Len(); i++) {
int u = Rnd.GetUniDevInt(CDegV.Len());
int v = Rnd.GetUniDevInt(NDegV.Len());
if (CNIDSet.IsKey(TIntPr(CDegV[u], NDegV[v]))) {
continue;
}
CNIDSet.AddKey(TIntPr(CDegV[u], NDegV[v]));
if (u == CDegV.Len() - 1) {
CDegV.DelLast();
} else {
CDegV[u] = CDegV.Last();
CDegV.DelLast();
}
if ( v == NDegV.Len() - 1) {
NDegV.DelLast();
} else {
NDegV[v] = NDegV.Last();
NDegV.DelLast();
}
}
}
for (int i = 0; i < CNIDSet.Len(); i++) {
TIntPr CNIDPr = CNIDSet[i];
IAssert(CmtyVH.IsKey(CNIDPr.Val1));
NewCmtyVH.AddDat(CNIDPr.Val1);
NewCmtyVH.GetDat(CNIDPr.Val1).Add(CNIDPr.Val2);
}
CmtyVH = NewCmtyVH;
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:45,代码来源:agm.cpp
示例13: printf
PLwOntoGround TLwOntoGround::GetOntoGround(
const PLwOnto& LwOnto, const PBowDocBs& BowDocBs,
const TStr& LangNm, const bool& DocCatIsTermIdP,
const double& CutWordWgtSumPrc){
printf("Generating Ontology-Classifier...\n");
// shortcuts
PLwTermBs TermBs=LwOnto->GetTermBs();
int Terms=TermBs->GetTerms();
PLwLinkBs LinkBs=LwOnto->GetLinkBs();
PLwLinkTypeBs LinkTypeBs=LwOnto->GetLinkTypeBs();
int LangId=LwOnto->GetLangBs()->GetLangId(LangNm);
int Docs=BowDocBs->GetDocs();
// create tfidf
printf(" Creating BowDocWgtBs ...");
PBowDocWgtBs BowDocWgtBs=TBowDocWgtBs::New(BowDocBs, bwwtNrmTFIDF);
PBowSim BowSim=TBowSim::New(bstCos);
printf(" Done.\n");
// collect documents per ontology-term
printf(" Collecting documents per ontology-term ...\n");
TIntIntVH TermIdToDIdVH; int PosCats=0; int NegCats=0;
for (int DId=0; DId<Docs; DId++){
printf(" Docs:%d/%d Pos:%d Neg:%d\r", 1+DId, Docs, PosCats, NegCats);
for (int DocCIdN=0; DocCIdN<BowDocBs->GetDocCIds(DId); DocCIdN++){
// get document-category
int CId=BowDocBs->GetDocCId(DId, DocCIdN);
TStr CatNm=BowDocBs->GetCatNm(CId);
// get term-id
if (DocCatIsTermIdP){
int TermId=CatNm.GetInt();
if (TermBs->IsTermId(TermId)){
TermIdToDIdVH.AddDat(TermId).Add(DId); PosCats++;
} else {NegCats++;}
} else {
if (TermBs->IsTermId(CatNm, LangId)){
int TermId=TermBs->GetTermId(CatNm, LangId);
TermIdToDIdVH.AddDat(TermId).Add(DId); PosCats++;
} else {NegCats++;}
}
}
}
printf(" Docs:%d/%d Pos:%d Neg:%d\n", Docs, Docs, PosCats, NegCats);
printf(" Done.\n");
// create sub-terms & up-terms vectors
printf(" Creating sub-terms & up-terms vectors ...");
TIntIntVH Const_TermIdToSubTermIdVH;
TIntIntVH TermIdToSubTermIdVH;
TIntIntVH TermIdToUpTermIdVH;
for (int TermN=0; TermN<Terms; TermN++){
int TermId=TermBs->GetTermId(TermN);
for (int LinkN=0; LinkN<LinkBs->GetFromLinks(TermId); LinkN++){
int LinkTypeId; int DstTermId;
LinkBs->GetFromLink(TermId, LinkN, LinkTypeId, DstTermId);
TStr LinkTypeNm=LinkTypeBs->GetLinkType(LinkTypeId)->GetLinkTypeNm();
if (LinkTypeNm=="NT"){
Const_TermIdToSubTermIdVH.AddDat(TermId).Add(DstTermId);
TermIdToSubTermIdVH.AddDat(TermId).Add(DstTermId);
TermIdToUpTermIdVH.AddDat(DstTermId).Add(TermId);
}
}
}
printf(" Done.\n");
// create centroids
printf(" Creating centroids ...\n");
THash<TInt, PBowSpV> TermIdToConceptSpVH;
TIntIntVH TermIdToSubTermDIdVH;
TIntH ProcTermIdH;
int PrevActiveTerms=-1;
forever{
// count active nodes for processing
int ActiveTerms=0;
for (int TermN=0; TermN<Terms; TermN++){
int TermId=TermBs->GetTermId(TermN);
if ((TermIdToSubTermIdVH.IsKey(TermId))&&
(TermIdToSubTermIdVH.GetDat(TermId).Len()>0)){
ActiveTerms++;
}
}
// stop if no change from previous round
printf(" Active-Terms:%d\n", ActiveTerms);
if (ActiveTerms==PrevActiveTerms){break;}
PrevActiveTerms=ActiveTerms;
// reduce active-nodes with zero-ancestors
for (int TermN=0; TermN<Terms; TermN++){
int TermId=TermBs->GetTermId(TermN);
if (ProcTermIdH.IsKey(TermId)){continue;}
if ((!TermIdToSubTermIdVH.IsKey(TermId))||
(TermIdToSubTermIdVH.GetDat(TermId).Len()==0)){
printf(" %d/%d\r", 1+TermN, Terms);
ProcTermIdH.AddKey(TermId);
// collect document-ids
TIntV TermDIdV;
if (TermIdToDIdVH.IsKey(TermId)){
TermDIdV.AddV(TermIdToDIdVH.GetDat(TermId));}
if (TermIdToSubTermDIdVH.IsKey(TermId)){
TermDIdV.AddV(TermIdToSubTermDIdVH.GetDat(TermId));}
// create concept-vector if any documents
if (TermDIdV.Len()>0){
PBowSpV ConceptSpV=
TBowClust::GetConceptSpV(BowDocWgtBs, BowSim, TermDIdV, CutWordWgtSumPrc);
TermIdToConceptSpVH.AddDat(TermId, ConceptSpV);
//.........这里部分代码省略.........
开发者ID:Accio,项目名称:snap,代码行数:101,代码来源:ontolight.cpp
示例14: Nodes
TGraphKey::TGraphKey(const TIntV& GraphSigV) : Nodes(-1), EdgeV(), SigV(), VariantId(0) {
SigV.Gen(GraphSigV.Len());
for (int i = 0; i < GraphSigV.Len(); i++) {
SigV[i] = TFlt(GraphSigV[i]());
}
}
开发者ID:pikma,项目名称:Snap,代码行数:6,代码来源:ghash.cpp
示例15: main
int main(int argc, char *argv[]) {
// #### SETUP: Parse Arguments
LogOutput Log;
THash<TStr, TStr> Arguments;
ArgumentParser::ParseArguments(argc, argv, Arguments, Log);
TStr OutputDirectory;
TStr StartString = ArgumentParser::GetArgument(Arguments, "start", "2009-02-01");
TStr QBDBDirectory = ArgumentParser::GetArgument(Arguments, "qbdb", QBDB_DIR_DEFAULT);
TStr OutDirectory = ArgumentParser::GetArgument(Arguments, "out", "/lfs/1/tmp/curis/");
TInt WindowSize = ArgumentParser::GetArgument(Arguments, "window", "14").GetInt();
if (ArgumentParser::GetArgument(Arguments, "nolog", "") == "") {
Log.DisableLogging();
} else if (!Arguments.IsKeyGetDat("directory", OutputDirectory)) {
Log.SetupNewOutputDirectory("");
} else {
Log.SetDirectory(OutputDirectory);
}
// #### DATA LOADING: Load ALL the things!
TQuoteBase QB;
TDocBase DB;
fprintf(stderr, "Loading QB and DB from file for %d days, starting from %s...\n", WindowSize.Val, StartString.CStr());
Err("%s\n", QBDBDirectory.CStr());
TSecTm PresentTime = TDataLoader::LoadQBDBByWindow(QBDBDirectory, StartString, WindowSize, QB, DB);
fprintf(stderr, "QBDB successfully loaded!\n");
TVec<TSecTm> PubTmV;
TVec<TStr> PostUrlV;
TVec<TStr> QuoteV;
fprintf(stderr, "Dumping quotes to file...\n");
TIntV QuoteIds;
QB.GetAllQuoteIds(QuoteIds);
for (int i = 0; i < QuoteIds.Len(); i++) {
TQuote Q;
QB.GetQuote(QuoteIds[i], Q);
TStr QContentString;
Q.GetContentString(QContentString);
TVec<TUInt> Sources;
Q.GetSources(Sources);
for (int j = 0; j < Sources.Len(); j++) {
TDoc D;
DB.GetDoc(Sources[j], D);
TStr PostUrl;
D.GetUrl(PostUrl);
TSecTm PostTime = D.GetDate();
QuoteV.Add(QContentString);
PubTmV.Add(PostTime);
PostUrlV.Add(PostUrl);
}
}
TFOut FOut(OutDirectory + "QuoteList" + ".bin");
PubTmV.Save(FOut);
PostUrlV.Save(FOut);
QuoteV.Save(FOut);
fprintf(stderr, "Done!\n");
return 0;
}
开发者ID:snap-stanford,项目名称:curis-2012,代码行数:63,代码来源:memedumpquote.cpp
示例16: GetAllNodes
void TempMotifCounter::Count3TEdge3NodeStars(double delta, Counter3D& pre_counts,
Counter3D& pos_counts,
Counter3D& mid_counts) {
TIntV centers;
GetAllNodes(centers);
pre_counts = Counter3D(2, 2, 2);
pos_counts = Counter3D(2, 2, 2);
mid_counts = Counter3D(2, 2, 2);
// Get counts for each node as the center
#pragma omp parallel for schedule(dynamic)
for (int c = 0; c < centers.Len(); c++) {
// Gather all adjacent events
int center = centers[c];
TVec<TIntPair> ts_indices;
TVec<StarEdgeData> events;
TNGraph::TNodeI NI = static_graph_->GetNI(center);
int index = 0;
TIntV nbrs;
GetAllNeighbors(center, nbrs);
int nbr_index = 0;
for (int i = 0; i < nbrs.Len(); i++) {
int nbr = nbrs[i];
AddStarEdgeData(ts_indices, events, index, center, nbr, nbr_index, 0);
AddStarEdgeData(ts_indices, events, index, nbr, center, nbr_index, 1);
nbr_index++;
}
ts_indices.Sort();
TIntV timestamps;
TVec<StarEdgeData> ordered_events;
for (int j = 0; j < ts_indices.Len(); j++) {
timestamps.Add(ts_indices[j].Key);
ordered_events.Add(events[ts_indices[j].Dat]);
}
ThreeTEdgeStarCounter tesc(nbr_index);
// dirs: outgoing --> 0, incoming --> 1
tesc.Count(ordered_events, timestamps, delta);
#pragma omp critical
{ // Update counts
for (int dir1 = 0; dir1 < 2; ++dir1) {
for (int dir2 = 0; dir2 < 2; ++dir2) {
for (int dir3 = 0; dir3 < 2; ++dir3) {
pre_counts(dir1, dir2, dir3) += tesc.PreCount(dir1, dir2, dir3);
pos_counts(dir1, dir2, dir3) += tesc.PosCount(dir1, dir2, dir3);
mid_counts(dir1, dir2, dir3) += tesc.MidCount(dir1, dir2, dir3);
}
}
}
}
// Subtract off edge-wise counts
for (int nbr_id = 0; nbr_id < nbrs.Len(); nbr_id++) {
int nbr = nbrs[nbr_id];
Counter3D edge_counts;
Count3TEdge2Node(center, nbr, delta, edge_counts);
#pragma omp critical
{
for (int dir1 = 0; dir1 < 2; ++dir1) {
for (int dir2 = 0; dir2 < 2; ++dir2) {
for (int dir3 = 0; dir3 < 2; ++dir3) {
pre_counts(dir1, dir2, dir3) -= edge_counts(dir1, dir2, dir3);
pos_counts(dir1, dir2, dir3) -= edge_counts(dir1, dir2, dir3);
mid_counts(dir1, dir2, dir3) -= edge_counts(dir1, dir2, dir3);
}
}
}
}
}
}
}
开发者ID:jsw883,项目名称:snap,代码行数:70,代码来源:temporalmotifs.cpp
|
请发表评论