• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TFltPrV类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TFltPrV的典型用法代码示例。如果您正苦于以下问题:C++ TFltPrV类的具体用法?C++ TFltPrV怎么用?C++ TFltPrV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TFltPrV类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: AddExpFit

int TGnuPlot::AddExpFit(const int& PlotId, const TGpSeriesTy& SeriesTy, const double& FitXOffset, const TStr& Style) {
  const TGpSeries& Plot = SeriesV[PlotId];
  if(Plot.XYValV.Empty()) return -1;
  const TFltKdV& XY = Plot.XYValV;
  double A, B, R2, SigA, SigB, Chi2;
  // power fit
  TFltPrV XYPr;
  int s;
  for (s = 0; s < XY.Len(); s++) {
    if (XY[s].Key-FitXOffset > 0) {
      XYPr.Add(TFltPr(XY[s].Key-FitXOffset, XY[s].Dat)); } //!!! skip zero values
  }
  TSpecFunc::ExpFit(XYPr, A, B, SigA, SigB, Chi2, R2);
  TStr Label, StyleStr=Style;
  if (FitXOffset == 0) { Label = TStr::Fmt("%.4g exp(%.4g x)  R^2:%.2g", A, B, R2); }
  else { Label = TStr::Fmt("%.4g exp(%.4g x - %g)  R^2:%.2g", A, B, FitXOffset, R2); }
  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
  const int FitId = AddFunc(TStr::Fmt("%f*exp(%f*x-%f)", A, B, FitXOffset),
    SeriesTy, Label, StyleStr);
  return FitId;
  /*SeriesV.Add();
  TGpSeries& NewPlot = SeriesV.Last();
  TFltKdV& EstXY = NewPlot.XYValV;
  for (s = 0; s < XYPr.Len(); s++) {
    EstXY.Add(TFltKd(XYPr[s].Val1+FitXOffset, A*exp(B*XYPr[s].Val1)));
  }
  NewPlot.SeriesTy = SeriesTy;
  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
  else { NewPlot.WithStyle = Style; }
  return SeriesV.Len() - 1;*/
}
开发者ID:mkrnc,项目名称:snap,代码行数:31,代码来源:gnuplot.cpp


示例2: AddErrBar

int TGnuPlot::AddErrBar(const TFltPrV& XYValV, const TFltV& DeltaYV, const TStr& Label) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
  }
  return AddErrBar(XYFltValV, DeltaYV, Label);
}
开发者ID:mkrnc,项目名称:snap,代码行数:7,代码来源:gnuplot.cpp


示例3: AddLogFit

int TGnuPlot::AddLogFit(const int& PlotId, const TGpSeriesTy& SeriesTy, const TStr& Style) {
  const TGpSeries& Plot = SeriesV[PlotId];
  if(Plot.XYValV.Empty()) return -1;
  const TFltKdV& XY = Plot.XYValV;
  double A, B, R2, SigA, SigB, Chi2;
  // power fit
  TFltPrV XYPr;
  int s;
  for (s = 0; s < XY.Len(); s++) {
    if (XY[s].Key > 0) {
      XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat)); } //!!! skip zero values
  }
  TSpecFunc::LogFit(XYPr, A, B, SigA, SigB, Chi2, R2);
  TStr StyleStr=Style;
  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
  const int FitId = AddFunc(TStr::Fmt("%f+%f*log(x)", A, B),
    SeriesTy, TStr::Fmt("%.4g + %.4g log(x)  R^2:%.2g", A, B, R2), StyleStr);
  return FitId;
  /*SeriesV.Add();
  TGpSeries& NewPlot = SeriesV.Last();
  TFltKdV& EstXY = NewPlot.XYValV;
  for (s = 0; s < XYPr.Len(); s++) {
    EstXY.Add(TFltKd(XYPr[s].Val1, A+B*log((double)XYPr[s].Val1)));
  }
  NewPlot.Label = TStr::Fmt("%.4g + %.4g log(x)  R^2:%.2g", A, B, R2);
  NewPlot.SeriesTy = SeriesTy;
  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
  else { NewPlot.WithStyle = Style; }
  return SeriesV.Len() - 1;*/
}
开发者ID:mkrnc,项目名称:snap,代码行数:30,代码来源:gnuplot.cpp


示例4: CalcEffDiam

double CalcEffDiam(const TFltPrV& DistNbrsCdfV, const double& Percentile) {
  TIntFltKdV KdV(DistNbrsCdfV.Len(), 0);
  for (int i = 0; i < DistNbrsCdfV.Len(); i++) {
    KdV.Add(TIntFltKd(int(DistNbrsCdfV[i].Val1()), DistNbrsCdfV[i].Val2));
  }
  return CalcEffDiam(KdV, Percentile);
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:7,代码来源:anf.cpp


示例5: AddPlot

int TGnuPlot::AddPlot(const TFltPrV& XYValV, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
  }
  return AddPlot(XYFltValV, SeriesTy, Label, Style);
}
开发者ID:mkrnc,项目名称:snap,代码行数:7,代码来源:gnuplot.cpp


示例6: IAssert

void TSirSR2Model::SetMediaBlogV(const TFltPrV& _MediaV, const TFltPrV& _BlogV) {
  IAssert(_MediaV.Len() == _BlogV.Len());
  MediaV.Clr(false);  BlogV.Clr(false);
  for (int i = 0; i < _MediaV.Len(); i++) {
    MediaV.Add(_MediaV[i].Val2);
    BlogV.Add(_BlogV[i].Val2);
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:8,代码来源:sir.cpp


示例7: Normalize

void TGUtil::Normalize(TFltPrV& PdfV) {
  double Sum = 0.0;
  for (int i = 0; i < PdfV.Len(); i++) {
    Sum += PdfV[i].Val2; }
  if (Sum <= 0.0) { return; }
  for (int i = 0; i < PdfV.Len(); i++) {
    PdfV[i].Val2 /= Sum; }
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:8,代码来源:util.cpp


示例8: GetValV

void TGStatVec::GetValV(const TGStatVal& XVal, const TGStatVal& YVal, TFltPrV& ValV) const {
  ValV.Gen(Len(), 0);
  double x;
  for (int t = 0; t < Len(); t++) {
    if (XVal == gsvTime) { x = t+1; }
    else { x = At(t)->GetVal(XVal); }
    ValV.Add(TFltPr(x, At(t)->GetVal(YVal)));
  }
}
开发者ID:Accio,项目名称:snap,代码行数:9,代码来源:gstat.cpp


示例9: TEST

// Test GetClustCf (Distribution and Closed and Open)
TEST(triad, TestGetClustCfDistCO) {
  const int ExpClosedTr = 3;  // Expected closed triads
  const int ExpOpenTr = 9;    // Expected open triads

  // Test TUNGraph
  PUNGraph GraphTUN = TriadGetTestTUNGraph();
  TFltPrV DegToCCfV;
  int64 ClosedTr = 0;
  int64 OpenTr = 0;

  TSnap::GetClustCf(GraphTUN, DegToCCfV, ClosedTr, OpenTr);
  TestDegToCCfVector(DegToCCfV);
  EXPECT_EQ(ExpClosedTr, ClosedTr);
  EXPECT_EQ(ExpOpenTr, OpenTr);

  // TNGraph should be treated as TUNGraph for calculations
  PNGraph GraphTN = TriadGetTestTNGraph();
  DegToCCfV.Clr();
  ClosedTr = 0;
  OpenTr = 0;

  TSnap::GetClustCf(GraphTN, DegToCCfV, ClosedTr, OpenTr);
  TestDegToCCfVector(DegToCCfV);
  EXPECT_EQ(ExpClosedTr, ClosedTr);
  EXPECT_EQ(ExpOpenTr, OpenTr);

  // TNEGraph is not treated the same! Be careful with multigraphs
  PNEGraph GraphTNE = TriadGetTestTNEGraph();
  DegToCCfV.Clr();
  ClosedTr = 0;
  OpenTr = 0;

  TSnap::GetClustCf(GraphTNE, DegToCCfV, ClosedTr, OpenTr);
  for (TFltPr *Pair = DegToCCfV.BegI(); Pair < DegToCCfV.EndI(); Pair++) {
    double Diff = Pair->Val2 - 5.0/9.0;   // Used for case 4
    Diff = (Diff < 0) ? -1.0*Diff : Diff; // Used for case 4
    switch ((int) Pair->Val1) {
      case 2:
        EXPECT_EQ(1.0, Pair->Val2);
        break;
      case 4:
        EXPECT_GT(0.00001, Diff); // Due to floats being imprecise
        break;
      case 7:
        EXPECT_EQ(2.0/3.0, Pair->Val2);
        break;
      case 15:
        EXPECT_EQ(0.3, Pair->Val2);
        break;
      default:
        ASSERT_FALSE(true); // Shouldn't have degrees other than listed
        break;
    }
  }
  EXPECT_EQ(ExpClosedTr, ClosedTr);
  EXPECT_EQ(ExpOpenTr, OpenTr);
}
开发者ID:Antobiotics,项目名称:snap,代码行数:58,代码来源:test-triad.cpp


示例10: PlotInvParticipRat

// Inverse participation ratio: normalize EigVec to have L2=1 and then I=sum_k EigVec[i]^4
// see Spectra of "real-world" graphs: Beyond the semicircle law by Farkas, Derenyi, Barabasi and Vicsek
void PlotInvParticipRat(const PUNGraph& Graph, const int& MaxEigVecs, const int& TimeLimit, const TStr& FNmPref, TStr DescStr) {
  TFltPrV EigIprV;
  GetInvParticipRat(Graph, MaxEigVecs, TimeLimit, EigIprV);
  if (DescStr.Empty()) { DescStr = FNmPref; }
  if (EigIprV.Empty()) { DescStr+=". FAIL"; EigIprV.Add(TFltPr(-1,-1)); return; }
  TGnuPlot::PlotValV(EigIprV, "eigIPR."+FNmPref, TStr::Fmt("%s. G(%d, %d). Largest eig val = %f (%d values)",
    DescStr.CStr(), Graph->GetNodes(), Graph->GetEdges(), EigIprV.Last().Val1(), EigIprV.Len()),
    "Eigenvalue", "Inverse Participation Ratio of corresponding Eigenvector", gpsLog10Y, false, gpwPoints);
}
开发者ID:Accio,项目名称:snap,代码行数:11,代码来源:statplot.cpp


示例11: MakeExpBins

void TGnuPlot::MakeExpBins(const TFltPrV& XYValV, TFltPrV& ExpXYValV, const double& BinFactor, const double& MinYVal) {
  TFltKdV KdV(XYValV.Len(), 0), OutV;
  for (int i = 0; i < XYValV.Len(); i++) {
    KdV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2)); }
  KdV.Sort();
  TGnuPlot::MakeExpBins(KdV, OutV, BinFactor, MinYVal);
  ExpXYValV.Gen(OutV.Len(), 0);
  for (int i = 0; i < OutV.Len(); i++) {
    ExpXYValV.Add(TFltPr(OutV[i].Key, OutV[i].Dat)); }
}
开发者ID:mkrnc,项目名称:snap,代码行数:10,代码来源:gnuplot.cpp


示例12: GetNEFromAccDistr

void GetNEFromAccDistr(const TFltPrV& deg, int& nodes, int& edges){
    double nodesD = deg[0].Val2.Val, edgesD = 0;
    for (int i = 0; i < deg.Len(); i++){
        if (i == deg.Len()-1)
            edgesD += deg[i].Val1.Val * deg[i].Val2.Val;
        else edgesD += deg[i].Val1.Val * (deg[i].Val2.Val - deg[i+1].Val2.Val);
    }
    nodes = static_cast<int>(nodesD);
    edges = static_cast<int>(edgesD);
    //	edges /= 2; as Deg = inDeg + outDeg
}
开发者ID:KronGen,项目名称:KronTest,代码行数:11,代码来源:InOut.cpp


示例13: GnuPlot

void TFfGGen::PlotFireSize(const TStr& FNmPref, const TStr& DescStr) {
  TGnuPlot GnuPlot("fs."+FNmPref, TStr::Fmt("%s. Fire size. G(%d, %d)",
    DescStr.CStr(), Graph->GetNodes(), Graph->GetEdges()));
  GnuPlot.SetXYLabel("Vertex id (iterations)", "Fire size (node out-degree)");
  TFltPrV IdToOutDegV;
  for (TNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
    IdToOutDegV.Add(TFltPr(NI.GetId(), NI.GetOutDeg())); }
  IdToOutDegV.Sort();
  GnuPlot.AddPlot(IdToOutDegV, gpwImpulses, "Node out-degree");
  GnuPlot.SavePng();
}
开发者ID:hdravna,项目名称:CommDet,代码行数:11,代码来源:ff.cpp


示例14: TEST

// Test GetClustCf (Distribution and Closed and Open)
TEST(triad, TestGetClustCfDistCO) {
  const int expected_closed = 3;  // Expected closed triads
  const int expected_open = 9;    // Expected open triads

  // Test TUNGraph
  PUNGraph Graph_TUNGraph = TriadGetTestTUNGraph();
  TFltPrV DegToCCfV;
  int64 closed = 0, open = 0;

  TSnap::GetClustCf(Graph_TUNGraph, DegToCCfV, closed, open);
  TestDegToCCfVector(DegToCCfV);
  EXPECT_EQ(expected_closed, closed);
  EXPECT_EQ(expected_open, open);

  // TNGraph should be treated as TUNGraph for calculations
  PNGraph Graph_TNGraph = TriadGetTestTNGraph();
  DegToCCfV.Clr();
  closed = 0, open = 0;

  TSnap::GetClustCf(Graph_TNGraph, DegToCCfV, closed, open);
  TestDegToCCfVector(DegToCCfV);
  EXPECT_EQ(expected_closed, closed);
  EXPECT_EQ(expected_open, open);

  // TNEGraph is not treated the same! Be careful with multigraphs
  PNEGraph Graph_TNEGraph = TriadGetTestTNEGraph();
  DegToCCfV.Clr();
  closed = 0, open = 0;

  TSnap::GetClustCf(Graph_TNEGraph, DegToCCfV, closed, open);
  for (TFltPr *pair = DegToCCfV.BegI(); pair < DegToCCfV.EndI(); pair++) {
    double diff = pair->Val2 - 5.0/9.0;   // Used for case 4
    diff = (diff < 0) ? -1.0*diff : diff; // Used for case 4
    switch ((int) pair->Val1) {
      case 2:
        EXPECT_EQ(1.0, pair->Val2);
        break;
      case 4:
        EXPECT_GT(0.00001, diff); // Due to floats being imprecise
        break;
      case 7:
        EXPECT_EQ(2.0/3.0, pair->Val2);
        break;
      case 15:
        EXPECT_EQ(0.3, pair->Val2);
        break;
      default:
        ASSERT_FALSE(true); // Shouldn't have degrees other than listed
        break;
    }
  }
  EXPECT_EQ(expected_closed, closed);
  EXPECT_EQ(expected_open, open);
}
开发者ID:Accio,项目名称:snap,代码行数:55,代码来源:test-triad.cpp


示例15: GetCumDistr

void GetCumDistr(const TFltPrV& nonCum, TFltPrV& res){
	for (int i = nonCum.Len() - 1; i >=0; i--){
		TFlt count;
		if (i == nonCum.Len() - 1)
			count = nonCum[i].Val2.Val;
		else
			count = nonCum[i].Val2.Val + res[res.Len()-1].Val2.Val;
		TFltPr val(nonCum[i].Val1, count);
		res.Add(val);
	}
	res.Sort();
}
开发者ID:kbochenina,项目名称:Snap,代码行数:12,代码来源:Plot.cpp


示例16: plotScatterLengthOfEachCascade

void plotScatterLengthOfEachCascade(THash<TUInt,TSecTmV>& c1, THash<TUInt,TSecTmV>& c2)
{
	printf("\n\nPlotting ...\n");
	TFltPrV plotdata;
	for(int q=0;q<c1.Len();q++)
	{
		TFltPr elem;
		elem.Val1 = c1[q].Len();
		elem.Val2 = c2[q].Len();
		plotdata.Add(elem);
	}
	Tools::plotScatter(plotdata, "TwitterUrlsOverContents", "Urls on Twitter", "Contents on Twitter");
}
开发者ID:omid55,项目名称:memestwrepo,代码行数:13,代码来源:plot_scatter_for_Twitter_only.cpp


示例17: plotScatterLengthOfEachCascade

void plotScatterLengthOfEachCascade(THash<TStr,CascadeElementV>& quotes, THash<TUInt,TSecTmV>& twitter, char* name)
{
	printf("\n\nPlotting ...\n");
	TFltPrV plotdata;
	for(int q=0;q<quotes.Len();q++)
	{
		TFltPr elem;
		elem.Val1 = quotes[q].Len();
		elem.Val2 = twitter[q].Len();
		plotdata.Add(elem);
	}
	Tools::plotScatter(plotdata, name, "Blogs/News", TStr::Fmt("%s on Twitter",name).CStr());
}
开发者ID:omid55,项目名称:memestwrepo,代码行数:13,代码来源:plot_scatter.cpp


示例18: plotParitialDegDistribution

void plotParitialDegDistribution(const PNGraph& graph, std::vector<int>& nodeList) {
	std::map<int, int> inDegDistMap;
	std::map<int, int> outDegDistMap;
	
	for (int i = 0; i < nodeList.size(); ++i) {
		int curNodeId = nodeList[i];
		if (!graph->IsNode(curNodeId)) continue;
		TNGraph::TNodeI ni = graph->GetNI(curNodeId);

		int curNodeInDeg = ni.GetInDeg();
		if (inDegDistMap.find(curNodeInDeg) == inDegDistMap.end()) {
			inDegDistMap.insert(std::pair<int, int>(curNodeInDeg, 0));
		}
		inDegDistMap[curNodeInDeg]++;

		int curNodeOutDeg = ni.GetOutDeg();
		if (outDegDistMap.find(curNodeOutDeg) == outDegDistMap.end()) {
			outDegDistMap.insert(std::pair<int, int>(curNodeOutDeg, 0));
		}
		outDegDistMap[curNodeOutDeg]++;
		
	}
	
	TFltPrV inDegDist;
	for (std::map<int, int>::iterator itr = inDegDistMap.begin(); itr != inDegDistMap.end(); itr++) {
		inDegDist.Add(TFltPr(itr->first, itr->second));
	}

	TFltPrV outDegDist;
	for (std::map<int, int>::iterator itr = outDegDistMap.begin(); itr != outDegDistMap.end(); itr++) {
		outDegDist.Add(TFltPr(itr->first, itr->second));
	}
	
	TGnuPlot plot1("inDegDistParitial", "");
	plot1.AddPlot(inDegDist, gpwPoints, "");
	plot1.SetScale(gpsLog10XY);
	plot1.SavePng();

	TGnuPlot plot2("outDegDistParitial", "");
	plot2.AddPlot(outDegDist, gpwPoints, "");
	plot2.SetScale(gpsLog10XY);
	plot2.SavePng();

	TGnuPlot plot3("DegDistParitial", "");
	plot3.AddCmd("set key right top");
	plot3.AddPlot(inDegDist, gpwPoints, "In Degree");
	plot3.AddPlot(outDegDist, gpwPoints, "Out Degree");
	plot3.SetScale(gpsLog10XY);
	plot3.SavePng();
}
开发者ID:ziyan,项目名称:unfollow,代码行数:50,代码来源:experiments.cpp


示例19: GenKron

void GenKron(const TStr& Args, TKronMtx& FitMtx, TFltPrV& KronDegAvgIn, TFltPrV& KronDegAvgOut){
	Env = TEnv(Args, TNotify::NullNotify);
	TExeTm ExecTime;
	// number of Kronecker graphs to generate
	const TInt NKron = Env.GetIfArgPrefixInt("-n:", 1, "Number of generated Kronecker graphs");
	// iterations of Kronecker product
	const TInt NIter = Env.GetIfArgPrefixInt("-i:", 10, "Iterations of Kronecker product");
	// is graph directed?
	TStr IsDir = Env.GetIfArgPrefixStr("-isdir:", "false", "Produce directed graph (true, false)");
	
	TFlt ExpectedNodes = FitMtx.GetNodes(NIter), ExpectedEdges = FitMtx.GetEdges(NIter);
	
	TFile << "Kronecker nodes: " << ExpectedNodes << ", expected Kronecker edges: " << ExpectedEdges << endl;
		
	double Sec = 0.0;
	int AvgMaxOutDeg = 0, AvgMaxInDeg = 0, MinMaxOutDeg = 0, MaxMaxOutDeg = 0, MinMaxInDeg = 0, MaxMaxInDeg = 0;
   bool Dir = IsDir == "true" ? true : false;

	for (int i = 0; i < NKron; i++){
		ExecTime.Tick();
      PNGraph Kron = TKronMtx::GenFastKronecker(FitMtx, NIter, Dir, 0);
		Sec += ExecTime.GetSecs();
		printf("Calculating maximum degree...\n");
		int MaxOutDeg = GetMaxMinDeg(Kron, IsDir, "false", "true"), MaxInDeg = GetMaxMinDeg(Kron, IsDir, "true", "true");
		CompareDeg(i, MaxOutDeg, MinMaxOutDeg, MaxMaxOutDeg, AvgMaxOutDeg);
		CompareDeg(i, MaxInDeg, MinMaxInDeg, MaxMaxInDeg, AvgMaxInDeg);

		//printf("Nodes count: %d, nodes with non-zero degree %d, edges count %d\n max deg = %d\n", kron->GetNodes(), TSnap::CntNonZNodes(kron), kron->GetEdges(), MaxDeg);
		if (i == NKron - 1){
			//TFile << "Clustering coefficient: " << TSnap::GetClustCf(kron) << endl;
			//TSnap::PlotClustCf(kron,"kronSingle");
			//TSnap::PlotHops(kron, "kronSingle");
			
			TFile << "Maximum output degree in kron graph: " << "from " << MinMaxOutDeg << " to " << MaxMaxOutDeg << " (average: " << (double)AvgMaxOutDeg / (double)NKron << ")" << endl;
			TFile << "Maximum input degree in kron graph: " << "from " << MinMaxInDeg << " to " << MaxMaxInDeg << " (average: " << (double)AvgMaxInDeg / (double)NKron << ")" << endl;
		}
		AddDegreesStat(KronDegAvgIn, Kron, true);
		AddDegreesStat(KronDegAvgOut, Kron, false);
	}
	Sec /= NKron;

	
    GetAvgDegreeStat(KronDegAvgIn, NKron);
    GetAvgDegreeStat(KronDegAvgOut, NKron);
	
	KronDegAvgIn.Sort();
	KronDegAvgOut.Sort();
	TFile << "Average time of generation of Kronecker product: " <<  Sec << endl;
}
开发者ID:KronGen,项目名称:KronTest,代码行数:49,代码来源:KronGen.cpp


示例20: getSampledDistance

void getSampledDistance(const PNGraph& graph, std::vector<int> srcIds, std::vector<int> dstIds, int sampleSize, TFltPrV& ret) {
	std::random_shuffle(srcIds.begin(), srcIds.end());
	std::random_shuffle(dstIds.begin(), dstIds.end());

	int distance[20];
	for (int i = 0; i < 20; distance[i++] = 0);

	int sampleCount = 0;
	for (int i = 0; i < sampleSize; ) {
		int srcNodeId = srcIds[rand() % srcIds.size()];
		int dstNodeId = dstIds[rand() % dstIds.size()];

		if (!graph->IsNode(srcNodeId)) continue;
		if (!graph->IsNode(dstNodeId)) continue;
		int shortDist = TSnap::GetShortPath(graph, srcNodeId, dstNodeId, true);
		distance[shortDist]++;
		sampleCount++;
		printIntArray(distance, 20);
		++i;
	}

	for (int i = 0; i < 20; ++i) {
		ret.Add(TFltPr(i, distance[i]));
	}
}
开发者ID:ziyan,项目名称:unfollow,代码行数:25,代码来源:experiments.cpp



注:本文中的TFltPrV类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TFltV类代码示例发布时间:2022-05-31
下一篇:
C++ TFitResultPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap