Esempio n. 1
0
  std::list<std::pair<typename WeightMap::value_type,
                      std::list<typename Graph::edge_descriptor>>>
  yen_ksp(const Graph& g, Vertex<Graph> s, Vertex<Graph> t,
          WeightMap wm, IndexMap im, boost::optional<unsigned> K, boost::optional<unsigned> length)
  {
    using kr_type = Result<typename WeightMap::value_type, Graph>;

    // The shortest paths - these we return.
    std::list<kr_type> A;

    // An empty result if the source and destination are the same.
    if (s != t)
      {
        // The tentative paths - these are candidate paths.  It's a
        // set, because we want to make sure that a given result can
        // show up in the set of tentative results only once.  The
        // problem is that the algorithm can find the same tentative
        // path many times.
        std::set<kr_type> B;

        // In each iteration we produce the k-th shortest path.
        for (int k = 1; !K || k <= K.value(); ++k) {
			
          if (!yen_ksp(g, s, t, wm, im, A, B)) {
			  // We break the loop if no path was found.
			  break;
          }
          if (length && A.back().second.size() > length.value()) {
			  // We break the loop if the maximum path length was exceeded
			  A.pop_back();
			  break;
		  }
        }
      }

    return A;
  }
Esempio n. 2
0
#include <boost/filesystem.hpp>
#include <gdbplz/connection.hpp>
#include "../Catch/include/catch.hpp"

TEST_CASE("guessing gdb path", "[connection]")
{
	boost::optional<boost::filesystem::path> path = gdbplz::guess_gdb_path();
	REQUIRE((!path || boost::filesystem::exists(path.value())) == true);
}

TEST_CASE("launching with non-existing gdb", "[connection]")
{
	REQUIRE_THROWS_AS([](){
		gdbplz::connection conn("/sfsfsdfwdsfwerfwef/xcvxvfsdfsdfwerwefrsgfdfgdfgergtergdfg");
	}(), gdbplz::gdb_not_found);
}