Beispiel #1
0
	pparser(std::string Params, bool dbg) 
	{
		// Initialize some things
		n_params = 0;
		debug = dbg;

		if (debug) std::cout << "--- DEBUG: Initializing pparser ---" << std::endl;

		params.open(Params.c_str(), std::ifstream::in);

		if (params)
		{
			if (debug) std::cout << "--- DEBUG: Parameter file opened ---" << std::endl;

			std::string temp;
			char t2;

			// Extract parameters from data
			while (params.get(t2))
			{
				temp += t2;

				if (t2 == '\n' || t2 == '/' || t2 == '\t')
				{
					temp.pop_back();
					if (debug) std::cout << "--- DEBUG: Extracted Values: ---\n" << temp << std::endl;

					while (t2 != '\n' && params.get(t2)) {}

					add_param(temp);

					temp = "";
				}
			}

			// Get inverse of initial permutation
			p.ii_perm = inverse_perm(p.i_perm);

			if (debug) {std::cout << "--- DEBUG: Printing contents of p ---" << std::endl; print(std::cout);}
			
			// Close file
			params.close();
		}
	}
// Compute a good row permutation given a column permutation for the
// sparse QR decomposition algorithm.
void row_order( const grid2 *g, const int *col_perm, int *row_perm )
{
  int size = Size(*g);
  int x, y, i, j, e;

  int *q = inverse_perm( col_perm, size );
  int *p = row_perm;

  for( i=0, j=0; i < size; ++i ) {
    Node(*g,q[i],x,y);
    
    if( InGrid2(*g,x-1,y) ) {
      e = HEIndex(*g,x-1,y);
      p[e] = j++;
    }

    if( InGrid2(*g,x,y-1) ) {
      e = VEIndex(*g,x,y-1);
      p[e] = j++;
    }
  }
  
  free_perm(q);
}
Beispiel #3
0
int main(int argc, char** argv)
{
	size_t size=1<<5;
	if(argc>1) size=1<<atoi(argv[1]);
	size_t ne=size*size/8 + 1;

	boost::mt19937 rng;
	if(argc>2){
		rng.seed(atoi(argv[2]));
	}

	typedef bald_t G;
	bald_t g;
	boost::generate_random_graph(g, size, ne, rng);
	size_t e=boost::num_edges(g);
	size_t n=boost::num_vertices(g);
	std::cout << "generated " << e << " edges, " << n << " vertices\n";

	BOOST_AUTO(EE, boost::edges(g));
	for(;EE.first!=EE.second; ++EE.first){
		auto s=boost::source(*EE.first, g);
		auto t=boost::target(*EE.first, g);
		if(!boost::edge(t, s, g).second){
			boost::add_edge(t, s, g);
		}
	}

	// boost::add_edge(0,1,g);
	e=boost::num_edges(g);

	std::cout << "symmetric " << e << " edges\n";

	unsigned i=0;
	BOOST_AUTO(E, boost::edges(g));
	for(;E.first!=E.second; ++E.first){
		++i;

		std::cout << boost::source(*E.first, g) << " -- " <<
			boost::target(*E.first, g) << "\n";

		if(i==5) break;

	}

	std::deque<unsigned long > iso;
	BOOST_AUTO(V, boost::vertices(g));
	for(;V.first!=V.second; ++V.first){
			if(boost::out_degree(*V.first, g)){

			}else{
				iso.push_back(*V.first);
			}
	}

#ifdef REMOVE_ISOLATED
	// no longer necessary.
	for(auto i: iso){
		boost::remove_vertex(i, g);
	}
#endif

	n = boost::num_vertices(g);

	V=boost::vertices(g);
	for(;V.first!=V.second; ++V.first){
		assert(*V.first<n);
//		assert(boost::out_degree(*V.first,g));
	}

	std::cout << "tagged " << iso.size() <<"\n";

	i = 0;
	// boost md does not like cliques.
	trace3("clique check", n, e, size);
	if((n*(n-1u)) == boost::num_edges(g)){ untested();
		exit(0);
	}else{
		itested();
	}

	std::vector<int> inverse_perm(n, 0);
	std::vector<int> supernode_sizes(n, 1);
	BOOST_AUTO(id, boost::get(boost::vertex_index, g));
	std::vector<int> degree(n, 0);
	std::vector<int> io(n, 0);
	std::vector<int> o(n, 0);

	G h(g);
	assert(boost::num_edges(g)==boost::num_edges(g));

//	assert(n + iso.size() == size);

	/*
	 * (Graph& g,
	 *  DegreeMap degree,
	 *  InversePermutationMap inverse_perm,
	 *  PermutationMap perm,
	 *  SuperNodeMap supernode_size,
	 *  int delta,
	 *  VertexIndexMap vertex_index_map)
	 */

	unsigned ub=-1;

	unsigned w =
#ifndef HAVE_MINDEGREE_FORK
		0;
	itested();
#endif
	boost::minimum_degree_ordering
		(g,
		 boost::make_iterator_property_map(&degree[0], id, degree[0]),
		 &io[0],
		 &o[0],
		 boost::make_iterator_property_map(&supernode_sizes[0], id, supernode_sizes[0]),
		 0,
		 id
#ifdef HAVE_MINDEGREE_FORK
		 , ub
#endif
		);
	typename treedec::graph_traits<G>::treedec_type t;
	g = h; // restore

	int status;
#ifdef TRY_INEFFICIENT_VARIANT
	treedec::ordering_to_treedec(g, o, t ); // can kill g!
   h=g; // restore

	status = treedec::check_treedec(g,t);
	std::cout << "bagsize " << treedec::get_bagsize(t) << " status " << status <<"\n";
	std::cout << "same as bagsize! " << w <<"\n";
	assert(w == treedec::get_bagsize(t)); /// checks if BMD works!
#endif

	treedec::draft::vec_ordering_to_tree(g, o, t );

	status=treedec::check_treedec(g, t);
	if (!status) std::cout << "treedec is valid!!\n";
	std::cout << "bagsize " << treedec::get_bagsize(t) << " status " << status <<"\n";
	std::cout << "boost_minDegree_ordering said " << w << "\n";
	assert(!status);

	if(w != treedec::get_bagsize(t)){
	}
	assert(w == treedec::get_bagsize(t));


}