Exemplo n.º 1
0
void print_board()
{
    int i, j;
        
    clear();
    print_edge("┌", "┐", "-");

    /* print info bar */
    char info[16];
    char info_fmt[16];

    myprintf("|");
    sprintf(info, " goal: %u score: %u ", count_goal(), SCORE);
    sprintf(info_fmt, "%%-%ds", SIZE * 6 - 1);
    myprintf(info_fmt, info);
    myprintf("|\n");

    /* print map */
    for (i = 0; i < SIZE; i++) {
        if (!i)
            print_edge("├", "┤", "┬");
        else
            print_edge("├", "┤", "┼");
        for (j = 0; j < SIZE; j++)
            myprintf("|%5d", BOARD[i][j]);
        myprintf("|\n");
    }
    print_edge("└", "┘", "┴");
}
Exemplo n.º 2
0
Arquivo: dot.c Projeto: gredman/yumbo
void print_state(state_t *state) {
	print_table(state->table1);
	if (state->table2) {
		print_table(state->table2);
		print_edge(state);
	}
}
Exemplo n.º 3
0
void print_edges(edges_list edges) {
  guint i, length=0;
  GList *e = NULL;
  
  length = queue_length(edges);
  e = edges->head;
  for (i=0; i<length; i++, e = e->next) {
    print_edge(e->data);
  }
}
Exemplo n.º 4
0
static rc_t CC on_dict_key_value( uint64_t key, uint64_t value, void * user_data )
{
    rc_t rc = 0;
    struct rna_splice_log * sl = ( struct rna_splice_log * )user_data;
    if ( sl != NULL )
    {
        char tmp[ 512 ];
        size_t num_writ;
        union dict_key_union ku;
        union dict_value_union vu;
        char intron;
        bool reverse_complement;

        ku.key = key;
        vu.value = value;
        intron = intron_type_to_ascii[ vu.entry.intron_type & 0x03 ];
        reverse_complement = ( ( vu.entry.intron_type & 0x03 ) == INTRON_REV );

        rc = string_printf ( tmp, sizeof tmp, &num_writ,
                             "%s\t%u\t%u\t%u\t%c\t",
                             sl->ref_name, ku.key_struct.pos + 1, ku.key_struct.len, vu.entry.count, intron );
        if ( rc == 0 )
            rc = write_to_file( sl, ( uint8_t * )tmp, num_writ );

        if ( reverse_complement )
        {
            if ( rc == 0 )
                rc = print_edge( sl, ku.key_struct.pos + ku.key_struct.len - 2, true, false );
            if ( rc == 0 )
                rc = print_edge( sl, ku.key_struct.pos, true, true );
        }
        else
        {
            if ( rc == 0 )
                rc = print_edge( sl, ku.key_struct.pos, false, false );
            if ( rc == 0 )
                rc = print_edge( sl, ku.key_struct.pos + ku.key_struct.len - 2, false, true );
        }
    }
    return rc;
}
Exemplo n.º 5
0
void SGraph::print(ion *out) const {
  for (SNodeIter iter = get_node_iterator();
       !iter.done(); iter.increment()) {
    print_node(out, iter.get());
    out->printf("\n");
    for (SNodeIter successor_iter(get_node_successor_iterator(iter.get()));
	 !successor_iter.done(); successor_iter.increment()) {
      print_edge(out, SGraphEdge(iter.get(), successor_iter.get()));
      out->printf("\n");
    }
  }
}
Exemplo n.º 6
0
void dot_visitor::write_to_file(const char *fname)
{
	std::ofstream out(fname);
	if(out.fail())
		return;
	print_begin(out);
	for(auto iter = node_list.begin(); iter != node_list.end(); ++iter)
	{
		print_node(out, *iter);
	}
	for(auto iter = edge_list.begin(); iter != edge_list.end(); ++iter)
	{
		print_edge(out, *iter);
	}
	print_end(out);
	out.flush();
}
Exemplo n.º 7
0
int main()
{
	int vc = 9334;
	int ec = 26841;
	vector_int edges;
	vector_int_init(&edges, ec * 2);

	srand((int)time(0));
	int src = -1, dst = -1;
	for (int i = 0, ei = 0; i < ec; i++,ei+=2) {
		src = (int)(rand() % vc);
		dst = (int)(rand() % vc);
		while (src == dst) {
			src = (int)(rand() % vc);
			dst = (int)(rand() % vc);
		}
		VECTOR(edges)[ei] = src;
		VECTOR(edges)[ei+1] = dst;
	}

	graph_t a;
	new_graph(&a, &edges, vc, 1);
	assert(vc == graph_vertices_count(&a));
	assert(ec == graph_edges_count(&a));
	printf("reciprocal = %f \n", graph_reciprocal(&a));
	int min, max, sum;
	double ave;
	graph_degree_minmax_avesum(&a, &min, &max, &ave, &sum, GRAPH_OUT, GRAPH_NO_LOOPS);
	printf("minout=%d\nmaxout=%d\n\n",min,max);
	printf("sum=%d\nave=%f\n\n\n",sum,ave);
	graph_degree_minmax_avesum(&a, &min, &max, &ave, &sum, GRAPH_IN, GRAPH_NO_LOOPS);
	printf("minin=%d\nmaxin=%d\n\n\n",min,max);
	printf("sum=%d\nave=%f\n\n\n",sum,ave);

	FILE * f = fopen("a.sif","w");
	print_edge(&edges, f);
    fclose(f);
	//print_graph_ct(&a, GRAPH_OUT, stdout);
}
Exemplo n.º 8
0
 id_els GraphOutput::construct_graph(string linear_seqs_name) // PIERRE: i need to know the last nb_nodes
{
    Bank *Nodes = new Bank((char *)linear_seqs_name.c_str());
    id_els nb_els = first_id_els; //Alexan: stucture for print id elements in graph output

    char * rseq;
    int readlen;

    Nodes->rewind_all();

    sizeKmer--; // nodes extremities overlap by (k-1)-mers, so let's extract (k-1)-mers

    // for each node, output all the out-edges (in-edges will correspond to out-edges of neighbors)
    while (Nodes->get_next_seq(&rseq,&readlen))
    {
	
        kmer_type left_kmer, right_kmer, left_kmer_fw, left_kmer_rc, right_kmer_fw, right_kmer_rc;
        set<node_strand>::iterator it;

        left_kmer = extractKmerFromRead(rseq,0,&left_kmer_fw,&left_kmer_rc, false);
        right_kmer = extractKmerFromRead(rseq,readlen-sizeKmer,&right_kmer_fw,&right_kmer_rc, false);
        Strand left_strand = (left_kmer == left_kmer_fw)?FW:RC;
        Strand right_strand = (right_kmer == right_kmer_fw)?FW:RC;


        // left edges (are revcomp extensions)
        for (it = kmer_links[left_kmer].begin(); it != kmer_links[left_kmer].end(); it++)
        {
            long cur_node = it->node;
            Strand cur_strand = it->strand;
            LeftOrRight cur_left_or_right = it->left_or_right;

            if (cur_node ==nb_els.node) // prevent self loops on same kmer
                 if (readlen == sizeKmer)
                    continue;
            
            string label = "R";

            if (cur_left_or_right == LEFT)
            {
                if (cur_strand != left_strand)
                    label+=(string)"F";
                else
                    continue;
            }
            else
            {
                if (cur_strand == left_strand)
                    label+=(string)"R";
                else
                    continue;
            }


            print_edge(nb_els.edge, nb_els.node,cur_node,label);
	        nb_els.edge++; 
        }

        // right edges
        for (it = kmer_links[right_kmer].begin(); it != kmer_links[right_kmer].end(); it++)
        {
            long cur_node = it->node;
            Strand cur_strand = it->strand;
            LeftOrRight cur_left_or_right = it->left_or_right;

            if (cur_node == nb_els.node) // prevent self loops on same kmer
                 if (readlen == sizeKmer)
                    continue;
           
            string label = "F";

            if (cur_left_or_right == LEFT)
            {
                if (cur_strand == right_strand)
                    label+=(string)"F";
                else
                    continue;
            }
            else
            {
                if (cur_strand != right_strand)
                    label+=(string)"R";
                else
                    continue;
            }

            print_edge(nb_els.edge, nb_els.node,cur_node,label);
	        nb_els.edge++;
        }

        //nodes
        print_node(nb_els.node, rseq);   

        nb_els.node++;
    }

    sizeKmer++; // make sure to restore k
    Nodes->close();
    delete Nodes;
    return nb_els;
}
Exemplo n.º 9
0
void SGraph::print_edge(ion *out, const SGraphEdge &edge,
			bool do_forward) const {
  if (do_forward) print_edge(out, edge); 
  else print_edge(out, edge.reverse()); }
Exemplo n.º 10
0
void test_edge_collapse() 
{
  std::cerr << "test_edge_collapse" << std::endl;

  PointMassList points;
  //use the stair example for testing
  load_xy_file<PointMassList, Point>("data/stair-noise00.xy", points);

  Point_property_map point_pmap;
  Mass_property_map  mass_pmap;

  CGAL::Optimal_transportation_reconstruction_2<K, Point_property_map, Mass_property_map>
    otr2(points, point_pmap, mass_pmap);

  const Rt_2& rt2 = otr2.tds();

  FT min_priority = 1000;
  R_edge_2 contract_edge;
  for (Finite_edges_iterator ei = rt2.finite_edges_begin();
       ei != rt2.finite_edges_end(); ++ei) 
  {
    if (rt2.is_pinned(*ei) || rt2.is_target_cyclic(*ei))
      continue;
    
    R_edge_2 cur_r_edge;
    if(!otr2.create_pedge(*ei, cur_r_edge))
      continue;

    print_edge(cur_r_edge);

    if (cur_r_edge.priority() < min_priority && cur_r_edge.priority() > 0) 
    {
      min_priority = cur_r_edge.priority();
      contract_edge = cur_r_edge;
    }
  }

  R_edge_2 pedge;
  otr2.pick_edge(0, pedge);

  std::cout << "--------" << std::endl;
  print_edge(contract_edge);

  print_edge(pedge);

  std::cout << "--------" << std::endl;

  //test that the right edge was picked for collapsing
  // N.B.: it can be two different edges if several edges have the same
  // priority value.
  assert(CGAL::abs(pedge.priority() - contract_edge.priority())
         < pedge.priority()*1e-13);
  otr2.do_collapse(contract_edge.edge());

  bool found = false;
  for (Finite_edges_iterator ei = rt2.finite_edges_begin();
       ei != rt2.finite_edges_end(); ++ei) 
  {
    if (*ei == contract_edge.edge()) 
    {
      found = true;
      break;
    }
  }

  //test that the edge was collapsed
  assert(!found);
  CGAL_USE(found);
}
Exemplo n.º 11
0
int is_min(struct gspan *gs)
{
	GHashTable *projection_map;
	GList *l1, *l2, *edges, *values = NULL;
	struct pre_dfs *pm;
	struct dfs_code *first_key, *start_code;
	int ret;

	//printf("g_list_length(dfs_codes) = %d\n", g_list_length(gs->dfs_codes));
	if (g_list_length(gs->dfs_codes) == 1) {
		//printf("heremin1\n");
		return 1;
	}

	g_list_free(gs->min_dfs_codes);
	gs->min_dfs_codes = NULL;

	if (gs->min_graph)
		graph_free(gs->min_graph);
	//print_dfs_list(gs->dfs_codes);
	gs->min_graph = build_graph_dfs(gs->dfs_codes);

	projection_map = g_hash_table_new(dfs_code_hash, glib_dfs_code_equal);

	for (l1=g_list_first(gs->min_graph->nodes); l1; l1=g_list_next(l1)) {
		struct node *n = (struct node *)l1->data;

		edges = get_forward_init(n, gs->min_graph);

		if (g_list_length(edges) == 0) {
			g_list_free(edges);
			continue;
		}

		for (l2 = g_list_first(edges); l2; l2 = g_list_next(l2)) {
			struct edge *e = (struct edge *)l2->data;
			struct node *from_node, *to_node;
			struct dfs_code *dfsc;
			struct pre_dfs *npdfs;
#ifdef DEBUG
			print_edge(e);printf("\n");
#endif
			from_node = graph_get_node(gs->min_graph, e->from);
			to_node = graph_get_node(gs->min_graph, e->to);

			dfsc = malloc(sizeof(struct dfs_code));
			if (!dfsc) {
				perror("malloc dfsc in is_min");
				exit(1);
			}
			dfsc->from = 0;
			dfsc->to = 1;
			dfsc->from_label = from_node->label;
			dfsc->edge_label = e->label;
			dfsc->to_label = to_node->label;

			npdfs = malloc(sizeof(struct pre_dfs));
			if (!npdfs) {
				perror("malloc npdfs in is_min");
				exit(1);
			}
			npdfs->id = 0;
			npdfs->edge = e;
			npdfs->prev = NULL;

			if (g_hash_table_contains(projection_map, dfsc))
				values = g_hash_table_lookup(projection_map, 
									dfsc);
			values = g_list_append(values, npdfs);
			g_hash_table_insert(projection_map, dfsc, values);
			values = NULL;
		}

		//g_list_free(edges);
		//edges = NULL;
	}

	l2 = g_hash_table_get_keys(projection_map);
	l2 = g_list_sort(l2, (GCompareFunc)dfs_code_project_compare);
	first_key = (struct dfs_code *)g_list_first(l2)->data;
	g_list_free(l2);

	start_code = malloc(sizeof(struct dfs_code));
	if (!start_code) {
		perror("malloc start_code in is_min");
		exit(1);
	}
	start_code->from = 0;
	start_code->to = 1;
	start_code->from_label = first_key->from_label;
	start_code->edge_label = first_key->edge_label;
	start_code->to_label = first_key->to_label;

	gs->min_dfs_codes = g_list_append(gs->min_dfs_codes, start_code);
	//print_dfs(g_list_nth_data(gs->dfs_codes, 
	//				g_list_length(gs->min_dfs_codes)-1));
	//printf("\n");
	//print_dfs(g_list_last(gs->min_dfs_codes)->data);
	//printf("\n");
	if (!dfs_code_equal(
				g_list_nth_data(gs->dfs_codes, 
					g_list_length(gs->min_dfs_codes)-1), 
				g_list_last(gs->min_dfs_codes)->data)) {
#ifdef DEBUG
		printf("heremin2\n");
#endif
		return 0;
	}
	values = g_hash_table_lookup(projection_map, first_key);
	ret = projection_min(gs, values);
	
	cleanup_map(projection_map);
	//g_list_free(values);
	//printf("ret = %d\n", ret);
	return ret;
}