コード例 #1
0
ファイル: acyclic.c プロジェクト: BestSean2016/graphviz
int main(int argc, char *argv[])
{
    Agraph_t *g;
    Agnode_t *n;
    int rv = 0;

    init(argc, argv);

    if ((g = agread(inFile,  (Agdisc_t *) 0)) != 0) {
	if (agisdirected (g)) {
	    aginit(g, AGNODE, "info", sizeof(Agnodeinfo_t), TRUE);
	    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
		if (ND_mark(n) == 0)
		    rv |= dfs(g, n, 0);
	    }
	    if (doWrite) {
		agwrite(g, outFile);
		fflush(outFile);
	    }
	    if (Verbose) {
		if (rv)
		    fprintf(stderr, "Graph \"%s\" has cycles; %d reversed edges\n", graphName(g), num_rev);
		else
		    fprintf(stderr, "Graph \"%s\" is acyclic\n", graphName(g));
	    }
	} else {
	    rv = -1;
	    if (Verbose)
		fprintf(stderr, "Graph \"%s\" is undirected\n", graphName(g));
	}
	exit(rv);
    } else
	exit(-1);
}
コード例 #2
0
	CGraphVector GetDefaultWeatherGraphVector(bool bHourly)
	{
		string XAxisTitle = GetString(IDS_WG_WEATHER_XAXIS_TITLE);
		StringVector graphName(GetString(IDS_WG_WEATHER_GRAPH_TITLE), ";|");
		StringVector leftYAxisTitle(GetString(IDS_WG_WEATHER_YAXIS_TITLE1), ";|");
		StringVector rightYAxisTitle(IDS_WG_WEATHER_YAXIS_TITLE2, ";|");


		CGraphVector graphics(NB_CHARTS);
		//load empty
		for (size_t c = 0; c < NB_CHARTS; c++)
		{

			graphics[c].m_name = graphName[c];
			//graphics[c].m_title = graphName[c];
			//graphics[c].m_Xtitle = XAxisTitle;
			graphics[c].m_Ytitle1 = leftYAxisTitle[c];
			graphics[c].m_Ytitle2 = rightYAxisTitle[c];
			graphics[c].m_bShowLegend = true;

			for (size_t v = 0; v < NB_VAR_MAX; v++)
			{
				int vv = bHourly ? DEFAULT_HOURLY_CHARTS[c][v] : DEFAULT_DAILY_CHARTS[c][v];
				if (vv >= 0)
					graphics[c].m_series.push_back(DEFAULT_WEATHER_SERIES[vv]);
			}
		}


		return graphics;
	}
コード例 #3
0
TF1* fitGraph( const std::string& outdir, TGraphErrors* graph, const std::string& axisName ) {


  //float xMin = 200.;
  //float xMax = 7000.;
  float xMin = 300.;

  TString grName_tstr(graph->GetName());

  std::string formula = "[0] + [1]*x";
  if( (grName_tstr.Contains("sigma") && grName_tstr.Contains("mm") && xMax>1100.) )
    formula = "[0] + [1]*x + [2]*x*x";
  if( ((grName_tstr.Contains("n2") || grName_tstr.Contains("alpha1") || grName_tstr.Contains("alpha2") ) && grName_tstr.Contains("5p6") ) ) 
    formula = "[0] + [1]*(x-2000.)*(x-2000.)";
  if( grName_tstr.Contains("n1") && grName_tstr.Contains("5p6") ) 
    formula = "[0] + [1]*(x-2000.)*(x-2000.) + [2]*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.) + [3]*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)";
  //if( grName_tstr.Contains("alpha1") && grName_tstr.Contains("0p014") ) 
  //  formula = "[0] + [1]*(x-2000.)*(x-2000.)  + [2]*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)*(x-2000.)";

  TF1* f1 = new TF1( Form("f1_%s", graph->GetName()), formula.c_str(), xMin, xMax );
  //TF1* f1 = new TF1( Form("f1_%s", graph->GetName()), "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + [5]*x*x*x*x*x", xMin, xMax );
  f1->SetLineColor(46);

  graph->SetMarkerStyle(20);
  graph->SetMarkerSize(2);
  graph->SetMarkerColor(46);

  std::string graphName(graph->GetName());
  TH1D* band;

  //TGraphErrors* graphToFit = new TGraphErrors(0);
  //int iPoint=0;
  //for( int i=0; i<graph->GetN(); ++i ) {
  //  Double_t x, y;
  //  graph->GetPoint(i, x, y);
  //  Double_t err_y = graph->GetErrorY(i);
  //  if( err_y/y > 0.00001 ) {
  //    graphToFit->SetPoint(iPoint, x, y);
  //    graphToFit->SetPointError(iPoint, 0., err_y);
  //    iPoint++;
  //  }
  //}
  //graphToFit->Fit( f1, "QR" );
  graph->Fit( f1, "QR" );
  f1->SetRange( xMin, xMax );
  band = ZGDrawTools::getBand(f1);

  TCanvas* c1 = new TCanvas( "c1", "", 600, 600 );
  c1->cd();

  float yMax = 0.;
  for( int i=0; i<graph->GetN(); ++i ) {
    Double_t x, y;
    graph->GetPoint(i, x, y);
    if( y>yMax ) yMax = y;
  }

  TH2D* h2_axes = new TH2D("axes", "", 10, xMin, xMax, 10, 0., 1.3*yMax );
  h2_axes->SetXTitle( "Mass [GeV]" );
  h2_axes->SetYTitle( axisName.c_str() );
  h2_axes->Draw();

  band->Draw("CE3same");
  graph->Draw("psame");

  
  ZGDrawTools::addLabels(c1, -1., "CMS Simulation");
  gPad->RedrawAxis();

  c1->SaveAs( Form("%s/fit_%s.eps", outdir.c_str(), graph->GetName()) );
  c1->SaveAs( Form("%s/fit_%s.pdf", outdir.c_str(), graph->GetName()) );

  delete c1;
  delete h2_axes;

  return f1;

}