Esempio n. 1
0
    void serialize(input_archive& ar,
        boost::dynamic_bitset<Block, Alloc>& bs, unsigned)
    {
        std::size_t num_bits;
        std::vector<Block> blocks;
        ar >> num_bits;
        ar >> blocks;

        bs.resize(num_bits);
        boost::from_block_range(blocks.begin(), blocks.end(), bs);
        bs.resize(num_bits);
    }
unsigned int cliqueHelper3(const boost_graph &g, const std::vector<VertexID> &nodes, const std::vector<EdgeID> &edges, double &score)
{
	static boost::dynamic_bitset<> empty;
	empty.resize(nodes.size());

	unsigned largest_clique = 1;
	boost::dynamic_bitset<> set(nodes.size());
	
	for (unsigned i = 0; i < nodes.size(); ++i)
	{
		set[i] = true;
	}

	int i = 0;
	while ((largest_clique <= 1 || i < 50000) && i < 100000)
	{
		// build the next potential clique.
		// every bit that is a 1 in set means that that node is in the clique.
		std::vector<VertexID> clique;
		randomize(set);
		set[0] = true; // the first bit is the query node.  must always be on.

		for (unsigned loop = 0; loop < nodes.size(); ++loop)
		{
			if (set[loop])
			{
				clique.push_back(nodes[loop]);
			}
		}

		// if this is a clique..
		double maybe_score = 0;
		if ((clique.size() > largest_clique) && isClique(g, clique, edges, maybe_score))
		{
			largest_clique = clique.size();
			score = maybe_score;
			std::cout << "Largest clique is " << largest_clique << std::endl;
		}
		//decrement(set);
		//increment(set);
		i++;
	}

	return largest_clique;
}
void SparseBipartiteGraph::convert_to_bitset(
		boost::dynamic_bitset<>& bits) const {

	std::vector < int > adj;

	unsigned int n = getNumberOfNodes() / 2;

	bits.resize(n * n);

	for (int u = 0; u < n; u++) {

		getNeighbors(u, adj);

		for (std::vector<int>::iterator it = adj.begin(); it != adj.end();
				++it) {

			int v = *it;

			unsigned int i = n * u + v - n;

			bits[n * n - i - 1] = 1;
		}
	}
}
Esempio n. 4
0
inline void insert_if_exists(boost::dynamic_bitset<>& cont, const boost::dynamic_bitset<> *other) {
	if (other && !other->empty()) {
		cont.resize(std::max(cont.size(), other->size()));
		cont |= *other;
	}
}
void DenseBipartiteGraph::get_row(int u, boost::dynamic_bitset<>& row) const {
	row.resize(ncols);
	for (int v = 0; v < ncols; v++) {
		row[v] = has_edge(u, v);
	}
}