Esempio n. 1
0
	void find_item(std::size_t& lenmax, const array_t::value_type& from, const array_t::value_type& to, array_t& path = array_t(), visited_t& visited = visited_t())
	{
		if (path.size() > lenmax)
			return;

		path.push_back(from);
		if (from->word_id == to->word_id)
		{
			lenmax = path.size() - 2;
			dump(path);
			return;
		}

		visited.insert(std::make_pair(from->word_id, 1));

		for (auto& s : from->similar) {

			auto hit = visited.find(s->word_id);
			if (hit != visited.end() && hit->second > 12535000) {
				hit_reached++;
				continue;
			}

			if (hit != visited.end())
				hit->second++;

			// исключить зацикливание
			if (std::find(path.begin(), path.end(), s) != path.end())
				continue;

			array_t another;
			another = path;
			find_item(lenmax, s, to, another, visited);
		}
	}
Esempio n. 2
0
set_set_t zdd_to_sets_rec( const zdd& z, visited_t& visited )
{
  using boost::adaptors::transformed;

  /* visited before? */
  auto it = visited.find( z.index );
  if ( it != visited.end() )
  {
    return it->second;
  }

  /* recur */
  auto high = zdd_to_sets_rec( z.high(), visited );
  auto low  = zdd_to_sets_rec( z.low(),  visited );

  boost::for_each( high, [&z]( set_t& s ) { s.set( z.var() ); } );

  set_set_t r;
  boost::push_back( r, high );
  boost::push_back( r, low );
  return r;
}