@@ -256,13 +256,24 @@ class grapht
256
256
void disconnect_unreachable (node_indext src);
257
257
void disconnect_unreachable (const std::vector<node_indext> &src);
258
258
259
+ // / Run recursive depth-limited search on the graph, starting
260
+ // / from a vector of start nodes, to find the nodes reachable within n steps,
261
+ // / excluding the start node unless a self loop exists.
262
+ // / \param from: vector of node indices to start from
263
+ // / \param depth: depth limit
264
+ // / \return set of node indices of reachable nodes
259
265
std::set<node_indext> depth_limited_search (
260
266
const std::vector<node_indext> &from,
261
267
std::size_t steps) const ;
262
268
263
- std::set<node_indext> depth_limited_search (
264
- node_indext from,
265
- std::size_t steps) const ;
269
+ // / Run recursive depth-limited search on the graph, starting
270
+ // / from a vector of start nodes, to find the nodes reachable within n steps,
271
+ // / excluding the start node unless a self loop exists.
272
+ // / \param from: node index to start from
273
+ // / \param depth: depth limit
274
+ // / \return set of node indices of reachable nodes
275
+ std::set<node_indext>
276
+ depth_limited_search (node_indext from, std::size_t steps) const ;
266
277
267
278
void make_chordal ();
268
279
@@ -287,6 +298,13 @@ class grapht
287
298
std::function<void (const node_indext &)> f) const ;
288
299
289
300
protected:
301
+ // / Run recursive depth-limited search on the graph, starting
302
+ // / from a vector of start nodes, to find the nodes reachable within n steps,
303
+ // / excluding the start node unless a self loop exists.
304
+ // / \param from: node index to start from
305
+ // / \param depth: depth limit
306
+ // / \param result: set of nodes that have been visited so far.
307
+ // / Reachable nodes are inserted into this set
290
308
void depth_limited_search (
291
309
node_indext from,
292
310
std::size_t depth,
@@ -598,51 +616,33 @@ std::vector<typename N::node_indext> grapht<N>::get_reachable(
598
616
return result;
599
617
}
600
618
601
- // / Run recursive depth-limited search on the graph, starting
602
- // / from a vector of start nodes, to find the nodes reachable within n steps,
603
- // / excluding the start node unless a self loop exists.
604
- // / \param from : vector of node indices to start from
605
- // / \param depth : depth limit
606
- // / \return set of node indices of reachable nodes
607
619
template <class N >
608
620
std::set<typename N::node_indext> grapht<N>::depth_limited_search(
609
- const std::vector<node_indext> &from, size_t depth) const
621
+ const std::vector<node_indext> &from,
622
+ size_t depth) const
610
623
{
611
624
std::set<node_indext> result;
612
625
for (const node_indext src : from)
613
626
depth_limited_search (src, depth, result);
614
627
return result;
615
628
}
616
629
617
- // / Run recursive depth-limited search on the graph, starting
618
- // / from a single start node, to find the nodes reachable within n steps,
619
- // / excluding the start node unless a self loop exists.
620
- // / \param from : index of node to start from
621
- // / \param depth : depth limit
622
- // / \return set of node indices of reachable nodes
623
630
template <class N >
624
- std::set<typename N::node_indext> grapht<N>::depth_limited_search(
625
- const node_indext from, size_t depth) const
631
+ std::set<typename N::node_indext>
632
+ grapht<N>::depth_limited_search( const node_indext from, size_t depth) const
626
633
{
627
634
std::set<node_indext> result;
628
- depth_limited_search (from, depth, result);
635
+ depth_limited_search (from, depth, result);
629
636
return result;
630
637
}
631
638
632
- // / Run recursive depth-limited search on the graph, starting
633
- // / from a single start node, to find the nodes reachable within n steps,
634
- // / excluding the start node unless a self loop exists.
635
- // / \param from : index of node to start from
636
- // / \param depth : depth limit
637
- // / \param result : set of node indices of nodes visited so far. Reachable
638
- // / nodes are added to this set
639
639
template <class N >
640
640
void grapht<N>::depth_limited_search(
641
641
node_indext from,
642
642
std::size_t depth,
643
643
std::set<node_indext> &result) const
644
644
{
645
- if (depth== 0 )
645
+ if (depth == 0 )
646
646
return ;
647
647
648
648
for (const auto o : nodes[from].out )
0 commit comments