/**
   * @brief This constructor creates the BGL graph from the map graph.
   * @param shm_segment the shared memory object name
   *
   * This constructor creates the BGL graph from the map graph that
   * is placed in the shared memory segment.
   */
  MyShmClient ( const char * shm_segment, std::string teamname ) : ShmClient ( shm_segment ), m_teamname ( teamname )
  {

    nr_graph = bgl_graph();

#ifdef DEBUG
    print_vertices ( 10 );
    print_edges ( 10 );
    std::fstream graph_log( teamname+".dot" , std::ios_base::out );
    boost::write_graphviz(graph_log, *nr_graph);		   
#endif

  }
예제 #2
0
//runs through nodes in cluster, finding their LCA's
int insert_graph(FILE *fp,char *file,int gsize) {
  int i,*freq,k = 0,numkeys,total;
  char *profile;
  KEY *node;
  struct hashnode_s *begin;

  if (!(edges = hashtbl_create(HASHSIZE,NULL))) {
    fprintf(stderr, "ERROR: hashtbl_create() failed");
    exit(EXIT_FAILURE);
  }

  fputs("digraph G {\n",fp);
  fprintf(fp,"\tlabel = \"%s\";\n",file);
  fprintf(fp,"\tpad = 0.5;\n");
  fprintf(fp,"\tnodesep = 0.5;\n");
  fprintf(fp,"\"\" [label=\"(0/%d)\"]\n",NUMSTRUCTS);
  //fputs("{ node [shape = plaintext]; ",fp);
  graphsize = gsize;
  if (INPUT) {
    i = process_one_input(fp);
    if (i > gsize)
      graphsize = i;
  }
  //printf("graphsize is %d for %s\n",*count,node->data);
  graph = malloc(sizeof(HASHTBL*)*(graphsize+1));
  for (i = 0; i <= graphsize; i++) graph[i] = NULL;
  /*print ranks
  for (i = 0; i < *count; i++) {
    fprintf(fp,"%d",i+1);
    if (i == *count-1)
      fprintf(fp,"; }\n");
    else
      fprintf(fp,"->");
  }
  */
  numkeys = hashtbl_numkeys(cluster);
  sums = malloc(sizeof(long)*numkeys);
  k = numkeys-1;
  profileID = malloc(sizeof(char*)*numkeys);
  modprofileID = malloc(sizeof(char*)*numkeys);
  most = 0;
  //for each profile, insert with freq
  
  for (node = hashtbl_getkeys(cluster); node; node = node->next) {
    //printf("node data is %s with k = %d\n",node->data,k);
    freq = hashtbl_get(cluster,node->data);
    //need to insert into graph

    if (freq) {
      if (most < *freq)
	most = *freq;
      profile = malloc(strlen(node->data)+1);
      sums[k] = insert_and_binary(node->data,profile,*freq);      
      profileID[k] = node->data;
      modprofileID[k--] = profile;
      if (*freq > 0)
	fprintf(fp,"\"%s\" [shape = box];\n",profile);
    }
    else
      fprintf(stderr,"No entry for %s\n",node->data);
    //printf("for profile %s binary rep is %d with ID %d\n",node->data,sums[k+1],k+1);
  }
  make_key();
  begin = insert_LCAs(fp,numkeys);
  //printf("inserted LCA's with numkeys %d\n",numkeys);
  add_infreq(begin);
  find_LCA_edges(fp,begin,numkeys);
  total = print_vertices(fp);
  printf("Total number of vertices: %d\n",total);
  if (INPUT)
    hashtbl_destroy(input);
  for (i = 0; i < graphsize; i++) {
    if (graph[i])
      hashtbl_destroy(graph[i]);
  }
  free(sums);
  free(table);
  free(profileID);
  free(modprofileID);
  hashtbl_destroy(edges);
  return 0;
}
예제 #3
0
int main ( )

/******************************************************************************/
/*
  Purpose:

    MAIN is the main program for TRIANGULATE.

  Modified:

    02 January 2013

  Author:

    Joseph O'Rourke

  Reference:

    Joseph ORourke,
    Computational Geometry,
    Second Edition,
    Cambridge, 1998,
    ISBN: 0521649765,
    LC: QA448.D38.
*/
{
  tVertex a;
  double area;
  int nvertices;
  tVertex p;
  int scale;
  int xmax;
  int xmin;
  int ymax;
  int ymin;

  read_vertices ( &nvertices );

  scale_data ( &xmin, &xmax, &ymin, &ymax, &scale );

  print_vertices ( nvertices, xmin, xmax, ymin, ymax, scale );

  area = 0.5 * ( double ) area_poly2 ( );

  printf ( "%%Area of polygon = %g\n", area );

  if ( area == 0.0 )
  {
    fprintf ( stderr, "\n" );
    fprintf ( stderr, "TRIANGULATE - Fatal error!\n" );
    fprintf ( stderr, "  Computed area of polygon is zero.\n" );
    exit ( 1 );
  }

  if ( area < 0.0 )
  {
    fprintf ( stderr, "\n" );
    fprintf ( stderr, "TRIANGULATE - Fatal error!\n" );
    fprintf ( stderr, "  Computed area of polygon is negative.\n" );
    fprintf ( stderr, "  The vertices are probably listed in clockwise order.\n" );
    fprintf ( stderr, "  Revise the input file by reversing the vertex order.\n" );
    exit ( 1 );
  }
/*
  Refuse to accept input if two consecutive vertices are equal.
*/
  p = vertices;
  a = p->next;
  do
  {
    if ( p->v[X] == a->v[X] && p->v[Y] == a->v[Y] )
    {
      fprintf ( stderr, "\n" );
      fprintf ( stderr, "TRIANGULATE - Fatal error!\n" );
      fprintf ( stderr, "  Vertices %d and %d are equal.\n", p->vnum, a->vnum );
      exit ( 1 );
    }
    p = a;
    a = p->next;
  } while ( a->next != vertices );
/*
  Compute the triangulation.
*/
  triangulate ( nvertices, xmin, xmax, ymin, ymax, scale );

  printf ( "showpage\n%%%%EOF\n" );
/*
  Terminate.
*/
  return 0;
}