コード例 #1
0
void reflexive_transitive_closure(unsigned int *R, int n)
{
	int rowsize;
	unsigned mask;
	unsigned *rp;
	unsigned *relend;

	transitive_closure(R, n);

	rowsize = WORDSIZE(n);
	relend = R + n * rowsize;

	mask = 1;
	rp = R;
	while (rp < relend)
	{
		*rp |= mask;
		mask <<= 1;
		if (mask == 0)
		{
			mask = 1;
			rp++;
		}

		rp += rowsize;
	}
}
コード例 #2
0
ファイル: trans_brute.cpp プロジェクト: igel-kun/transEd
void cap_k(t_dir_graph* d, const uint max_k){
	t_arc a;
	set<t_vertex> vertices = d->get_vertices();
	uint r;
	set<t_vertex>::iterator j;
	t_vertex v;

	transitive_closure(d);
	srand(time(NULL));
	for(uint i = 0; i < max_k; i++){
		do{
			// get a random arc
			r = (uint)floor((((rand()+1)*(double)vertices.size()))/(double)RAND_MAX);
			j = vertices.begin();
			while(r){
				r--;
				j++;
			}
			v = *j;

			r = (uint)floor((((rand()+1)*(double)vertices.size()))/(double)RAND_MAX);
			j = vertices.begin();
			while(r){
				r--;
				j++;
			}
		} while(v == *j);
		a = t_arc(v,*j);
		if(d->contains_arc(a)) d->delete_arc(a); else d->insert_arc(a);
	}
}
コード例 #3
0
ファイル: warshall.c プロジェクト: Mirocow/balancer
void reflexive_transitive_closure(unsigned *R, int n)
{
    register int rowsize;
    register unsigned i;
    register unsigned *rp;
    register unsigned *relend;

    transitive_closure(R, n);

    rowsize = WORDSIZE(n);
    relend = R + n * rowsize;

    i = 0;
    rp = R;
    while (rp < relend)
    {
	*rp |= (1 << i);
	if (++i >= BITS_PER_WORD)
	{
	    i = 0;
	    rp++;
	}

	rp += rowsize;
    }
}
コード例 #4
0
    void transitive_closure_dispatch
      (const Graph & g, GraphTC & tc,
       G_to_TC_VertexMap g_to_tc_map, VertexIndexMap index_map)
    {
      typedef typename graph_traits < GraphTC >::vertex_descriptor tc_vertex;
      typename std::vector < tc_vertex >::size_type
        n = is_default_param(g_to_tc_map) ? num_vertices(g) : 1;
      std::vector < tc_vertex > to_tc_vec(n);

      transitive_closure
        (g, tc,
         choose_param(g_to_tc_map, make_iterator_property_map
                      (to_tc_vec.begin(), index_map, to_tc_vec[0])),
         index_map);
    }
コード例 #5
0
//! TODO: we should not use graph_t here, but templates instead...
void transitive_reduction_of_dag(graph_t* out_graph, const graph_t* in_graph)
{
#if 0
	typedef graph_traits<graph_t>::vertex_iterator vitr;
	/*std::pair<vertex_iter, vertex_iter> vp;
	int* ptr = result.data();
	for (vp = vertices(S); vp.first != vp.second; ++vp.first)*/

	std::pair<vitr, vitr> range;
	for (vitr itr = range.first; itr != range.second; ++itr)
	for (vitr itr = range.first; itr != range.second; ++itr)
	for (vitr itr = range.first; itr != range.second; ++itr)
	if edges xy and yz exist
	delete edge xy
#endif
#if 0
	graph_t trans_cl, in_copy = *in_graph;
	transitive_closure(trans_cl, in_copy);

	graph_t trans_cl_copy;

	typedef property_map<graph_t, vertex_index_t>::type vidx_map;

/*	typedef indirect_cmp<vidx_map, std::greater<vidx_map::value_type> > idx_greater;
	vidx_map imap1 = get(vertex_index, trans_cl);
	idx_greater compare(imap1);
	typedef graph_traits<graph_t>::edge_descriptor edge_descr;

	std::priority_queue<edge_descr, std::vector<edge_descr>, idx_greater> idx_q;
*/
	edge_index_cmp cmp(trans_cl_copy);
	std::priority_queue<edge_descr, std::vector<edge_descr>, edgeFirstIdxCompare> idx_q(trans_cl_copy);

	/*push all edge into q*/
	typename graph_traits<graph_t>::edge_iterator ei, eiend;
	for (boost::tie(ei, eiend) = edges(trans_cl_copy); ei != eiend; ++ei)
	 idx_q.push(*ei);
#endif

}
コード例 #6
0
ファイル: depmap.c プロジェクト: lamproae/cflow
void
depmap_tc(cflow_depmap_t dmap)
{
     transitive_closure(dmap->r, dmap->nrows);
}