Exemplo n.º 1
0
Graph makePairsGraph(const RNAProfileAliMapType &inputMapProfile, const Algebra<double,RNA_Alphabet_Profile> *alg, const Matrix<double> *score_mtrx, double threshold) {
    Graph graph;
    RNAProfileAliMapType::const_iterator it,it2;
    RNAProfileAlignment *f1=NULL,*f2=NULL;

    graph = NewGraph(score_mtrx->xDim());

    for (int i=0; i<score_mtrx->xDim(); i++) {
        Xcoord(graph,i+1) = 0;
        Ycoord(graph,i+1) = 0;
    }

    for (it=inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        f1=it->second;
        for (it2=inputMapProfile.begin(); it2->first<it->first; it2++) {
            double score;
            f2=it2->second;

            score=score_mtrx->getAt(it->first-1,it2->first-1);
            if (alg->choice(score,threshold) != threshold) { // is it better than the threshold ?
                AddEdge (graph,it->first,it2->first,(int)(score*100.0));
            }
        }
    }


    WriteGraph (graph,(char*)"test.out");
    return graph;
}
Exemplo n.º 2
0
GRAPH *
CopyGraph(GRAPH *graph)
{
    GRAPH *ret;
    struct _keyed *k;
    struct dveclist *link, *newlink;

    ret = NewGraph();
    bcopy(graph, ret, sizeof(GRAPH)); /* va: compatible pointer types */

    ret->graphid = RunningId - 1;   /* restore id */

    /* copy keyed */
    for (ret->keyed = NULL, k = graph->keyed; k; k = k->next)
        SaveText(ret, k->text, k->x, k->y);

    /* copy dvecs */
    ret->plotdata = NULL;
    for (link = graph->plotdata; link; link = link->next) {
        newlink = TMALLOC(struct dveclist, 1);
        newlink->next = ret->plotdata;
        newlink->vector = vec_copy(link->vector);
        /* vec_copy doesn't set v_color or v_linestyle */
        newlink->vector->v_color = link->vector->v_color;
        newlink->vector->v_linestyle = link->vector->v_linestyle;
        newlink->vector->v_flags |= VF_PERMANENT;
        ret->plotdata = newlink;
    }

    ret->commandline = copy(graph->commandline);
    ret->plotname = copy(graph->plotname);

    return (ret);
}
Exemplo n.º 3
0
void GUI(void){	
  SetDefaultLineType(0);
  DefineGraphNxN_R("phi", &phi[0][0], &xdim, &ydim, NULL);
  DefineGraphNxN_R("psi", &psi[0][0], &xdim, &ydim, NULL);
  DefineGraphNxN_R("rho", &rho[0][0], &xdim, &ydim, NULL); 
  NewGraph();

  StartMenu("Ising Bilayer",1);

  SetActiveGraph(0);
  DefineGraph(contour2d_,"Visualize");

  //StartMenu("Controls",0);
  DefineInt("iterations", &iterations);
  DefineInt("repeat", &repeat);
  //DefineInt("stabilize", &stabilize);
  DefineDouble("phi_init", &r_zero[0]);
  DefineDouble("psi_init", &r_zero[1]);
  DefineDouble("Temperature", &T);
  DefineDouble("Lambda", &lambda);
  //EndMenu();

  StartMenu("Secondary Inputs",0);
  DefineInt("xdim", &xdim);
  DefineInt("ydim", &ydim);
  EndMenu();

  DefineFunction("reinitialize",&Init);

  DefineBool("Pause",&Pause);
  DefineBool("Single Step",&singlestep);
  DefineBool("Done",&done);	
  EndMenu();
}
Exemplo n.º 4
0
// loads new values 
void CInteractiveGraphView::ReloadGraphData()
{
	int n;

	pDoc=GetDocument();
	ASSERT_VALID(pDoc);
    

	// load the array type...
	CurrentGraph.LoadQuantities(pDoc->GetProblem(), 0, NULL, NULL, NULL, NULL, NULL);	

	// find the new number of points
	CData xQuantity;
	CurrentGraph.GetXQuantity(xQuantity);
	
 	if (xQuantity.type==SPACE_ARRAY)
		n = pDoc->GetProblem()->GetNode()->GetNodeCount();
	else if (xQuantity.type==TIME_ARRAY)
		n = pDoc->GetProblem()->GetStatus()->time_step+2;	// index 0 is SS, index 1 is t=0
	CurrentGraph.SetNumPoints(n);

    // load the new data      
	CurrentGraph.LoadQuantities(pDoc->GetProblem(), n, x, y[0], y[1], y[2], y[3]);


	// get labels
	CData yQuantity;
	CurrentGraph.GetYQuantity(0, yQuantity);

	CString title, ylabel, xlabel;

	title=CurrentGraph.GetTitle();
	xlabel=CurrentGraph.GetXLabel();
	ylabel=CurrentGraph.GetYLabel();
	if (title.IsEmpty())  title  = yQuantity.label;
	if (xlabel.IsEmpty()) xlabel = xQuantity.label+" ("+xQuantity.units+")";
	if (ylabel.IsEmpty()) ylabel = yQuantity.units; 

	// set the graph data
	int i;	                         
	NewGraph(title);
	SetXArray(n, x, xlabel, xQuantity.label, xQuantity.units, xQuantity.abbreviation);
	for (i=0; i<CurrentGraph.NumberOfValidCurves(); i++)
	{
		CurrentGraph.GetYQuantity(i, yQuantity);
		SetNextYArray(n, y[i], ylabel, yQuantity.label, yQuantity.units, yQuantity.abbreviation);
	}
//	if (!m_bAutoscale) 
//		SetDataLimits(m_xmin, m_xmax, CurrentGraph.xScale, m_ymin, m_ymax, CurrentGraph.yScale);
}
Exemplo n.º 5
0
main()
{
    cmdScannerADT cs;
    scannerADT scanner;
    graphADT graph;

    printf("Graph test program\n");
    cs = NewCommandScanner();
    scanner = GetTokenScanner(cs);
    SetScannerStringOption(scanner, ScanQuotesAsStrings);
    graph = NewGraph();
    SetGraphData(graph, NewSymbolTable());
    SetCommandData(cs, graph);
    InitCommandTable(cs);
    CommandLoop(cs, "G> ");
    FreeCommandScanner(cs);
}
Exemplo n.º 6
0
void test1()
{
  matrix *dmx;
  NewMatrix(&dmx, 4, 4);
  G *graph;

  dmx->data[0][1] = dmx->data[1][0] = 0.3;
  dmx->data[0][2] = dmx->data[2][0] = 0.4;
  dmx->data[0][3] = dmx->data[3][0] = 0.7;
  dmx->data[1][2] = dmx->data[2][1] = 0.9;
  dmx->data[1][3] = dmx->data[3][1] = 0.2;
  dmx->data[2][3] = dmx->data[3][2] = 0.1;
  PrintMatrix(dmx);
  NewGraph(&graph);
  GenerateAdjMX(dmx, 0.8, &graph);
  PrintGraph(graph);
  DelMatrix(&dmx);
  DelGraph(&graph);
}
Exemplo n.º 7
0
/*
 * Arma el grafo para graficar.
 */
graphADT
BuildPreliminarGraph(listADT list)
{
	graphADT g = NewGraph();
	actInfo * info, * auxInfo;
	stageADT stg = NULL;

/*Lista de precedentes insertados que llegan al sumidero. Drain Connected Precendences.*/
	listInfADT dcp;	

/*Lista de precedentes insertados que no llegan al sumidero. Non Drain Connected Precedences.*/
	listInfADT ndcp;

/*Lista de precedentes no creados. Non Created Precedences.*/
	listInfADT ncp;	

	listInfADT mergeList;
	listInfADT auxList = list;	/*Se recorrera sobre esta lista.*/
	activityADT act, auxAct;

	while(!listInfIsEmpty(auxList))
	{ 
		
		dcp = newInfList();					/*Inicializo las listas.*/
		ndcp = newInfList();
		ncp = newInfList();
		mergeList = newInfList();
		
		info = listInfHead(list);
		act = InsertActivity(g, info, NULL, GetDrain(g));			/*Creo la actividad y la
																	conecto al sumidero.*/
		if(strcmp(info->precedencies[0], "Fuente"))				
		{								/*Si las precedencias NO son la fuente*/						
			stg = InsertStage(g);		/*genero una nueva etapa y la conecto a ella.*/
			SetActivityOrig(g, info->ID, stg);
		}
		SetPrecedencesLists(g, list, &ncp, &dcp, &ndcp, info->precedencies);		/*Armo las listas.*/
		
		if(!listInfIsEmpty(ncp))
		{
			stg = InsertStage(g);
			while(!listInfIsEmpty(ncp))
			{
				auxInfo = listInfHead(ncp);
				auxAct = InsertActivity(g, auxInfo, NULL, stg);
				ncp = listInfTail(ncp);
			}
		}
		if(!listInfIsEmpty(ndcp))
		{
			if(stg == NULL)
			{
				stg = InsertStage(g);					/*Setea al nodo nuevo*/
				SetActivityOrig(g, info->ID, stg);		/*como origen de la actividad.*/	
			}
			mergeList = MergeLists(ndcp, info->precedencies);
			CreateFictitious(g, mergeList);
		}
		if(!listInfIsEmpty(dcp))
		{
			if(stg == NULL)
				stg = InsertStage(g);	/*Sus precedencias que terminaban en el sumidero*/
			ConnectPrecDestStage(g, dcp, stg);	/*ahora apuntan a la nueva act.*/	
		}
		if(stg == NULL && IsSourcePrec(info->precedencies))	/*Si la fuente esta como*/
			SetActivityOrig(g, info->ID, GetSource(g));	/*precedencia, la conecto con ella.*/
		stg = NULL;
		auxList = listInfTail(list);
		
		freeInfList(&dcp);
		freeInfList(&ndcp);
		freeInfList(&ncp);
		freeInfList(&mergeList);
	}
}
Exemplo n.º 8
0
Arquivo: graf.c Projeto: imr/ngspice
int
gr_init(double *xlims, double *ylims, /* The size of the screen. */
        char *xname, char *plotname,  /* What to label things. */
        char *hcopy,                  /* The raster file. */
        int nplots,                   /* How many plots there will be. */
        double xdelta, double ydelta, /* Line increments for the scale. */
        GRIDTYPE gridtype,            /* The grid type */
        PLOTTYPE plottype,            /*  and the plot type. */
        char *xlabel, char *ylabel,   /* Labels for axes. */
        int xtype, int ytype,         /* The types of the data graphed. */
        char *pname,
        char *commandline)            /* For xi_zoomdata() */
{
    GRAPH *graph;
    wordlist *wl;
    char *comb_title;

    NG_IGNORE(nplots);

    if ((graph = NewGraph()) == NULL)
        return (FALSE);

    /*
      The global currentgraph will always be the current graph.
    */
    SetGraphContext(graph->graphid);

    graph->onevalue = (xname ? FALSE : TRUE);

    /* communicate filename to plot 5 driver */
    if (hcopy)
        graph->devdep = hcopy;

    cur.plotno = 0;

    /* note: should do only once, maybe in gr_init_once */
    if (!cp_getvar("pointchars", CP_STRING, pointchars, sizeof(pointchars)))
        (void) strcpy(pointchars, DEFPOINTCHARS);

    if (!cp_getvar("ticmarks", CP_NUM, &graph->ticmarks, 0)) {
        if (cp_getvar("ticmarks", CP_BOOL, NULL, 0))
            graph->ticmarks = 10;
        else
            graph->ticmarks = 0;
    }

    if (cp_getvar("ticlist", CP_LIST, ticlist, 0)) {
        wl = vareval("ticlist");
        ticlist = wl_flatten(wl);
        graph->ticdata = readtics(ticlist);
    } else {
        graph->ticdata = NULL;
    }

    if (!xlims || !ylims) {
        internalerror("gr_init:  no range specified");
        return (FALSE);
    }

    /* save upper and lower limits */
    graph->data.xmin = xlims[0];
    graph->data.xmax = xlims[1];
    graph->data.ymin = ylims[0];
    graph->data.ymax = ylims[1];

    /* get title into plot window */
    if (!pname)
        pname = "(unknown)";
    if (!plotname)
        plotname = "(unknown)";

    comb_title = tprintf("%s: %s", pname, plotname);
    graph->plotname = comb_title;

    /* note: have enum here or some better convention */
    if (NewViewport(graph) == 1) {
        /* note: where is the error message generated? */
        /* note: undo tmallocs */
        fprintf(cp_err, "Can't open viewport for graphics.\n");
        return (FALSE);
    }

    /* layout decisions */
    /* note: have to do before gr_fixgrid and after NewViewport */
    graph->viewportxoff = graph->fontwidth * 8;  /* 8 lines on left */
    graph->viewportyoff = graph->fontheight * 4; /* 4 on bottom */

    DevClear();

    graph->grid.gridtype = gridtype;
    graph->plottype = plottype;
    graph->grid.xdatatype = xtype;
    graph->grid.ydatatype = ytype;
    graph->grid.xdelta = xdelta;
    graph->grid.ydelta = ydelta;
    graph->grid.ysized = 0;
    graph->grid.xsized = 0;

    if (!graph->onevalue) {
        if (xlabel)
            graph->grid.xlabel = xlabel;
        else
            graph->grid.xlabel = xname;

        if (ylabel)
            graph->grid.ylabel = ylabel;
    } else {
        if (xlabel)
            graph->grid.xlabel = xlabel;
        else
            graph->grid.xlabel = "real";

        if (ylabel)
            graph->grid.ylabel = ylabel;
        else
            graph->grid.ylabel = "imag";
    }

    gr_resize_internal(graph);
    gr_redrawgrid(graph);

    /* Set up colors and line styles. */
    if (dispdev->numlinestyles == 1)
        cur.linestyle = 0; /* Use the same one all the time. */
    else
        cur.linestyle = 1;

    /* XXX Special exception for SMITH */
    if (dispdev->numcolors > 2 &&
        (graph->grid.gridtype == GRID_SMITH ||
         graph->grid.gridtype == GRID_SMITHGRID))
    {
        cur.color = 3;
    } else {
        cur.color = 1;
    }

    graph->commandline = copy(commandline);

    return (TRUE);
}
Exemplo n.º 9
0
/*
 *      Places traces in a particular linear order
 *      to maximize sequential transition.
 *      A good way to achieve this is to construct a
 *      higher level graph, using traces as nodes.
 *      An arc is added between traces whose head
 *      and tail are connected by a transition.
 */
static void
PlaceTraces (FGraph graph)
{
  FGraph new_graph;
  Node node, current;
  Node node_order[MAX_GRAPH_SIZE];
  int i, size;
#ifndef SECOND_LEVEL_SELECT
  int min_trace_id, max_trace_id;
#endif
  if (graph->nodes == 0)
    return;
#ifdef SECOND_LEVEL_SELECT
  new_graph = NewGraph ();      /* create a high level graph */
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      int trace_id;
      Node temp;
      trace_id = nodeType (node);
      temp = FindNode (new_graph, trace_id);
      if (temp == 0)
        {
          temp = NewNode ();
          nodeId (temp) = trace_id;
          AddNode (new_graph, temp);
        }
      if (node == graph->root)
        new_graph->root = temp;
    }
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      Arc arc;
      if (!(nodeStatus (node) & TRACE_TAIL))
        continue;
      /*
       *      Find transitions to the head of other traces.
       *      Inner loop back-edge is not considered.
       */
      for (arc = destinationArcs (node); arc != 0; arc = nextArc (arc))
        {
          Node dest;
          dest = destinationNode (arc);
          if ((nodeType (dest) != nodeType (node)) &&
              (nodeStatus (dest) & TRACE_HEAD))
            {
              /*
               *      Add a link (trace[node]->trace[dest])
               */
              int src_trace_id, dest_trace_id;
              Node src_node, dest_node;
              Arc ar;
              src_trace_id = nodeType (node);
              dest_trace_id = nodeType (dest);
              src_node = FindNode (new_graph, src_trace_id);
              dest_node = FindNode (new_graph, dest_trace_id);
              ConnectNodes (src_node, dest_node, 0);
              ar = FindSrcArc (src_node, dest_node, 0);
              arcWeight (ar) = arcWeight (arc);
              ar = FindDestArc (src_node, dest_node, 0);
              arcWeight (ar) = arcWeight (arc);
            }
        }
    }
  /*
   *  Simply assign the node weights to max(connecting arc)
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      Arc arc;
      double max = 1.0;
      for (arc = sourceArcs (node); arc != 0; arc = nextArc (arc))
        if (arcWeight (arc) > max)
          max = arcWeight (arc);
      for (arc = destinationArcs (node); arc != 0; arc = nextArc (arc))
        if (arcWeight (arc) > max)
          max = arcWeight (arc);
      nodeWeight (node) = max;
    }
  /*
   *  Apply SelectTraces() on the new graph.
   *  Use SELECT_BY_ARC_WEIGHT
   */
  best_successor_of = best_successor_2;
  best_predecessor_of = best_predecessor_2;
  SelectTraces (new_graph);
  /*
   *  Determine the best sequential order of the traces.
   *  Essentially, we have the original problem again.
   *  However, after the second level trace selection,
   *  we expect most of the sequential transitions are
   *  captured. A naive heuristic is sufficient here.
   *  The sequential order must start with the ENTRY trace.
   */
#ifdef DEBUG_TRACE1
  printf ("... second level graph = \n");
  WriteGraph ("stdout", new_graph);
#endif
  /*
   *  Clear the valid bit of all nodes.
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      nodeStatus (node) &= ~VISITED;
    }
  /*
   *  Start from the root node.
   */
  size = 0;
  current = new_graph->root;
  while (current != 0)
    {
      Node ptr;
      Arc ar;
      int trace_id;
      if (nodeStatus (current) & VISITED)
        Punt ("PlaceTraces: reached a VISITed node");
      nodeStatus (current) |= VISITED;
      trace_id = nodeId (current);
      /*
       *      Layout the trace.
       */
      for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr))
        {
          if ((nodeType (ptr) == trace_id) && (nodeStatus (ptr) & TRACE_HEAD))
            break;              /* find the starting node of the trace */
        }
      if (ptr == 0)
        Punt ("PlaceTraces: internal error (1)");
      while (ptr != 0)
        {
          Arc next;
          node_order[size++] = ptr;
          /*
           *  Follow the in-trace transition.
           */
          if (nodeStatus (ptr) & TRACE_TAIL)
            break;              /* reached the end of trace */
          for (next = destinationArcs (ptr); next != 0; next = nextArc (next))
            {
              if (arcType (next) == nodeType (ptr))
                break;          /* find a in-trace transition */
            }
          if (next == 0)
            break;
          ptr = destinationNode (next);
        }
      /*
       *      Select the next trace to be visited next.
       *      Follow an in-trace transition (of the higher level
       *      graph) if possible. 
       */
      for (ar = destinationArcs (current); ar != 0; ar = nextArc (ar))
        {
          if (arcType (ar) == nodeType (current))
            break;              /* find an in-trace transition */
        }
      if (ar != 0)
        {                       /* transition is still in-trace */
          current = destinationNode (ar);
        }
      else
        {                       /* must find another trace */
          /*
           *  Find the most important trace left.
           */
          Node nn, best;
          best = 0;
          for (nn = new_graph->nodes; nn != 0; nn = nextNode (nn))
            {
              if (nodeStatus (nn) & VISITED)
                continue;       /* skip over VISITED nodes */
              if (!(nodeStatus (nn) & TRACE_HEAD))
                continue;       /* skip over non-trace headers */
              if (best == 0)
                {
                  best = nn;
                }
              else
                {
                  if (nodeWeight (nn) > nodeWeight (best))
                    best = nn;
                }
            }
          current = best;       /* go out of trace if best=0 */
        }
    }
  /*
   *  Make sure that all traces have been layout.
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      if (!(nodeStatus (node) & VISITED))
        {
          Punt ("PlaceTraces: missing some traces");
        }
    }
  /*
   *  No longer need the higher level graph.
   */
  FreeGraph (&new_graph);       /* destroy the high level graph */
#else
  min_trace_id = 0x1FFFFFFF;
  max_trace_id = -0x1FFFFFFF;
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      int trace_id;
      trace_id = nodeType (node);
      if (trace_id > max_trace_id)
        max_trace_id = trace_id;
      if (trace_id < min_trace_id)
        min_trace_id = trace_id;
    }
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      nodeStatus (node) &= ~VISITED;
    }
  size = 0;
  for (i = min_trace_id; i <= max_trace_id; i++)
    {
      Node ptr;
      /*
       * 1. find the trace header.
       */
      for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr))
        {
          if ((nodeType (ptr) == i) & ((nodeStatus (ptr) & TRACE_HEAD) != 0))
            break;
        }
      if (ptr == 0)
        continue;
      while (ptr != 0)
        {
          Arc next;
          if (nodeStatus (ptr) & VISITED)
            Punt ("PlaceTraces: visited a node twice");
          nodeStatus (ptr) |= VISITED;
          node_order[size++] = ptr;
          if (nodeStatus (ptr) & TRACE_TAIL)
            break;
          for (next = destinationArcs (ptr); next != 0; next = nextArc (next))
            {
              if (arcType (next) == nodeType (ptr))
                break;
            }
          if (next == 0)
            break;
          ptr = destinationNode (next);
        }
    }
  /*
   *  Make sure that all traces have been layout.
   */
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      if (!(nodeStatus (node) & VISITED))
        {
          fprintf (stderr, "min trace id = %d\n", min_trace_id);
          fprintf (stderr, "max trace id = %d\n", max_trace_id);
          fprintf (stderr, "size = %d\n", size);
          WriteGraph ("stderr", graph);
          Punt ("PlaceTraces: missing some traces");
        }
    }
#endif
  /*
   *  Rearrange the order of nodes, according to the
   *  node_order[] order.
   */
  node_order[size] = 0;
  for (i = 0; i < size; i++)
    {
      nextNode (node_order[i]) = node_order[i + 1];
    }
  graph->nodes = node_order[0];
}
Exemplo n.º 10
0
void CInteractiveGraphView::ShowHistoryGraph(int historytoshow)
{
	double zoomxmin, zoomxmax, zoomymin, zoomymax;
	GetCurrentGraphLimits(zoomxmin, zoomxmax, zoomymin, zoomymax);
	CScaleType xscale, yscale;
	xscale=GetXScaleType(); yscale=GetYScaleType();

	if (historytoshow<0) {
		ReloadGraphData();
		RescaleGraphData();
		if (m_bRetainZoom && CurrentGraph.xScale==xscale && CurrentGraph.yScale==yscale)
			SetZoom(zoomxmin, zoomxmax, zoomymin, zoomymax);
		return;
	}

	int n, k;
	double xmin, xmax, ymin, ymax, ymin0, ymax0;
	CString title, ylabel, xlabel;           

	pDoc=GetDocument();
	ASSERT_VALID(pDoc);

	int graphindex= m_NextFreeHistoryGraph-1-historytoshow;
	if (graphindex<0) graphindex+=MAXGRAPHSTOSAVE;

	// load the array type...
	m_HistoryGraph[graphindex].LoadQuantities(pDoc->GetProblem(), 0, NULL, NULL, NULL, NULL, NULL);	
	CData xQuantity, yQuantity;
	m_HistoryGraph[graphindex].GetXQuantity(xQuantity);
	
	n=m_HistoryGraph[graphindex].GetNumPoints();

	// find data bounds
	CMath::ArrayMinMax(n, m_HistoryX[graphindex], xmin, xmax);
	CMath::ArrayMinMax(n, m_HistoryY[0][graphindex], ymin, ymax);
	
	for (k=1; k<m_HistoryGraph[graphindex].NumberOfValidCurves(); k++)
	{
		CMath::ArrayMinMax(n, m_HistoryY[k][graphindex], ymin0, ymax0);
		if (ymin0<ymin) ymin = ymin0; if (ymax0>ymax) ymax = ymax0;
	}

	// get labels
	m_HistoryGraph[graphindex].GetYQuantity(0, yQuantity);

	title=m_HistoryGraph[graphindex].GetTitle();
	xlabel=m_HistoryGraph[graphindex].GetXLabel();
	ylabel=m_HistoryGraph[graphindex].GetYLabel();
	if (title.IsEmpty())  title  = yQuantity.label;
	if (xlabel.IsEmpty()) xlabel = xQuantity.label+" ("+xQuantity.units+")";
	if (ylabel.IsEmpty()) ylabel = yQuantity.units; 

	CString fulltitle;
	fulltitle.Format("Previous simulation #%d - %s", historytoshow+1, title);
	CString str;
	str=m_HistoryName[graphindex];
	if (!str.IsEmpty()) fulltitle += " - " + str;
	NewGraph(fulltitle);
	SetXArray(n, m_HistoryX[graphindex], xlabel, xQuantity.label, xQuantity.units, xQuantity.abbreviation);
	int i;	                         
	for (i=0; i<m_HistoryGraph[graphindex].NumberOfValidCurves(); i++)
	{
		CurrentGraph.GetYQuantity(i, yQuantity);
		SetNextYArray(n, m_HistoryY[i][graphindex], ylabel, yQuantity.label, yQuantity.units, yQuantity.abbreviation);
	}

	SetDataLimits(xmin, xmax, m_HistoryGraph[graphindex].xScale, ymin, ymax, m_HistoryGraph[graphindex].yScale);

	if (m_bRetainZoom && m_HistoryGraph[graphindex].xScale==xscale && m_HistoryGraph[graphindex].yScale==yscale)
		SetZoom(zoomxmin, zoomxmax, zoomymin, zoomymax);


//	if (m_bAutoscale) SetDataLimits(xmin, xmax, CurrentGraph.xScale, ymin, ymax, CurrentGraph.yScale);
//	else SetDataLimits(m_xmin, m_xmax, CurrentGraph.xScale, m_ymin, m_ymax, CurrentGraph.yScale);
}