示例#1
0
int
run_net_flow (FILE *f, int argc, char **argv)
{
  char line[128];
  NetFlow *nf = net_flow_new ();
  int caps[] = { 1900, 300, 100, 30, 10, 3, 1, 0 };
  int seed;

  seed = net_flow_find_node (nf, "-");
  net_flow_add_edge (nf, "-", "raph");
  net_flow_add_edge (nf, "-", "alan");
  net_flow_add_edge (nf, "-", "wsanchez");
  net_flow_add_edge (nf, "-", "rasmus");

  for (;;)
    {
      char *from;
      char *to;
      char *color;

      if (fgets (line, sizeof(line), f) == NULL)
	break;
      if (get_graph_line (line, &from, &to, &color))
	net_flow_add_edge (nf, from, to);
    }
  net_flow_max_flow (nf, seed, caps, sizeof(caps)/sizeof(caps[0]));
  return 0;
}
示例#2
0
int
run_page_rank (FILE *f, int argc, char **argv)
{
  char line[128];
  PageRank *pr = page_rank_new ();
  int seed;
  double *r;

  seed = page_rank_find_node (pr, "-");
  page_rank_add_edge (pr, "-", "rillian");

  for (;;)
    {
      char *from;
      char *to;
      char *color;

      if (fgets (line, sizeof(line), f) == NULL)
	break;
      if (get_graph_line (line, &from, &to, &color))
	page_rank_add_edge (pr, from, to);
    }
  r = page_rank_compute (pr, seed, 0.15);
#if 0
  print_page_rank (pr, r);
#endif
  g_free (r);
  return 0;
}
示例#3
0
文件: params.cpp 项目: nixz/covise
void put_annotation(int, FILE *pp, int imbed)
{
    int i;
    boxtype b;
    linetype l;
    plotstr s;
    char imbedstr[2];

    if (imbed)
    {
        strcpy(imbedstr, "@");
    }
    else
    {
        imbedstr[0] = 0;
    }
    for (i = 0; i < MAXBOXES; i++)
    {
        get_graph_box(i, &b);
        if (b.active == ON)
        {
            fprintf(pp, "%swith box\n", imbedstr);
            fprintf(pp, "%s    box on\n", imbedstr);
            fprintf(pp, "%s    box loctype %s\n", imbedstr, w_or_v(b.loctype));
            if (b.loctype == WORLD)
            {
                fprintf(pp, "%s    box g%1d\n", imbedstr, b.gno);
            }
            fprintf(pp, "%s    box %.12lg, %.12lg, %.12lg, %.12lg\n", imbedstr, b.x1, b.y1, b.x2, b.y2);
            fprintf(pp, "%s    box linestyle %d\n", imbedstr, b.lines);
            fprintf(pp, "%s    box linewidth %d\n", imbedstr, b.linew);
            fprintf(pp, "%s    box color %d\n", imbedstr, b.color);
            switch (b.fill)
            {
            case PLOT_NONE:
                fprintf(pp, "%s    box fill none\n", imbedstr);
                break;
            case COLOR:
                fprintf(pp, "%s    box fill color\n", imbedstr);
                break;
            case PATTERN:
                fprintf(pp, "%s    box fill pattern\n", imbedstr);
                break;
            }
            fprintf(pp, "%s    box fill color %d\n", imbedstr, b.fillcolor);
            fprintf(pp, "%s    box fill pattern %d\n", imbedstr, b.fillpattern);
            fprintf(pp, "%sbox def\n", imbedstr);
        }
    }

    for (i = 0; i < MAXLINES; i++)
    {
        get_graph_line(i, &l);
        if (l.active == ON)
        {
            fprintf(pp, "%swith line\n", imbedstr);
            fprintf(pp, "%s    line on\n", imbedstr);
            fprintf(pp, "%s    line loctype %s\n", imbedstr, w_or_v(l.loctype));
            if (l.loctype == WORLD)
            {
                fprintf(pp, "%s    line g%1d\n", imbedstr, l.gno);
            }
            fprintf(pp, "%s    line %.12lg, %.12lg, %.12lg, %.12lg\n", imbedstr, l.x1, l.y1, l.x2, l.y2);
            fprintf(pp, "%s    line linewidth %d\n", imbedstr, l.linew);
            fprintf(pp, "%s    line linestyle %d\n", imbedstr, l.lines);
            fprintf(pp, "%s    line color %d\n", imbedstr, l.color);
            fprintf(pp, "%s    line arrow %d\n", imbedstr, l.arrow);
            fprintf(pp, "%s    line arrow size %lf\n", imbedstr, l.asize);
            fprintf(pp, "%s    line arrow type %d\n", imbedstr, l.atype);
            fprintf(pp, "%sline def\n", imbedstr);
        }
    }

    for (i = 0; i < MAXSTR; i++)
    {
        get_graph_string(i, &s);
        if (s.active == ON && s.s[0])
        {
            fprintf(pp, "%swith string\n", imbedstr);
            fprintf(pp, "%s    string on\n", imbedstr);
            fprintf(pp, "%s    string loctype %s\n", imbedstr, w_or_v(s.loctype));
            if (s.loctype == WORLD)
            {
                fprintf(pp, "%s    string g%1d\n", imbedstr, s.gno);
            }
            fprintf(pp, "%s    string %.12lg, %.12lg\n", imbedstr, s.x, s.y);
            fprintf(pp, "%s    string linewidth %d\n", imbedstr, s.linew);
            fprintf(pp, "%s    string color %d\n", imbedstr, s.color);
            fprintf(pp, "%s    string rot %d\n", imbedstr, s.rot);
            fprintf(pp, "%s    string font %d\n", imbedstr, s.font);
            fprintf(pp, "%s    string just %d\n", imbedstr, s.just);
            fprintf(pp, "%s    string char size %lf\n", imbedstr, s.charsize);
            fprintf(pp, "%sstring def \"%s\"\n", imbedstr, s.s);
        }
    }
}