diff --git a/include/nifty/graph/detail/search_impl.hxx b/include/nifty/graph/detail/search_impl.hxx index 5bf2b1431..fbbc71e72 100644 --- a/include/nifty/graph/detail/search_impl.hxx +++ b/include/nifty/graph/detail/search_impl.hxx @@ -32,7 +32,7 @@ namespace detail_graph{ public: typedef GRAPH GraphType; - typedef typename GraphType:: template NodeMap PredecessorsMap; + typedef typename GraphType:: template NodeMap PredecessorsMap; typedef typename GraphType:: template NodeMap DistanceMap; private: typedef QUEUE Queue; @@ -165,7 +165,7 @@ namespace detail_graph{ VISITOR && visitor ){ this->initializeMaps(sourceBegin, sourceEnd); - this->runImpl(subgraphMask,visitor); + this->runImpl(subgraphMask, visitor); } const DistanceMap & distances()const{ @@ -181,7 +181,7 @@ namespace detail_graph{ class VISITOR > void runImpl( - const SUBGRAPH_MASK & subgraphMask, + const SUBGRAPH_MASK & subgraphMask, VISITOR && visitor ){ auto continueSeach = true; diff --git a/src/python/lib/graph/export_undirected_graph_class_api.hxx b/src/python/lib/graph/export_undirected_graph_class_api.hxx index 515b14360..ff3e85601 100644 --- a/src/python/lib/graph/export_undirected_graph_class_api.hxx +++ b/src/python/lib/graph/export_undirected_graph_class_api.hxx @@ -243,14 +243,19 @@ namespace graph{ " tuple : pair of node indexes / enpoints of the edge." ) - .def("bfsEdges",[](G & g, const std::size_t maxDistance){ + .def("bfsEdges",[](G & g, const std::size_t maxDistance, const bool exactDistance){ BreadthFirstSearch bfs(g); std::vector> pairs; g.forEachNode([&](const uint64_t sourceNode){ bfs.graphNeighbourhood(sourceNode, maxDistance, - - [&](const uint64_t targetNode, const uint64_t ){ + [&](const uint64_t targetNode, const uint64_t distance){ + if(targetNode < sourceNode){ + return; + } + if(exactDistance && (distance != maxDistance)){ + return; + } pairs.emplace_back(sourceNode, targetNode); } ); @@ -258,15 +263,16 @@ namespace graph{ xt::pytensor out({int64_t(pairs.size()), int64_t(2)}); - auto c=0; + auto c = 0; for(const auto & uv : pairs){ - out(c,0) = uv.first; - out(c,1) = uv.second; + out(c, 0) = uv.first; + out(c, 1) = uv.second; + ++c; } return out; }, - py::arg("maxDistance") + py::arg("maxDistance"), py::arg("exactDistance")=false ) .def("uvIds", [](G & g) {