forked from libigl/libigl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bfs.h
54 lines (52 loc) · 1.36 KB
/
bfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef IGL_BFS_H
#define IGL_BFS_H
#include "igl_inline.h"
#include <Eigen/Core>
#include <vector>
#include <Eigen/Sparse>
namespace igl
{
// Traverse a **directed** graph represented by an adjacency list using
// breadth first search
//
// Inputs:
// A #V list of adjacency lists or #V by #V adjacency matrix
// s starting node (index into A)
// Outputs:
// D #V list of indices into rows of A in the order in which graph nodes
// are discovered.
// P #V list of indices into rows of A of predecessor in resulting
// spanning tree {-1 indicates root/not discovered), order corresponds to
// V **not** D.
template <
typename AType,
typename DerivedD,
typename DerivedP>
IGL_INLINE void bfs(
const AType & A,
const size_t s,
Eigen::PlainObjectBase<DerivedD> & D,
Eigen::PlainObjectBase<DerivedP> & P);
template <
typename AType,
typename DType,
typename PType>
IGL_INLINE void bfs(
const std::vector<std::vector<AType> > & A,
const size_t s,
std::vector<DType> & D,
std::vector<PType> & P);
template <
typename AType,
typename DType,
typename PType>
IGL_INLINE void bfs(
const Eigen::SparseCompressedBase<AType> & A,
const size_t s,
std::vector<DType> & D,
std::vector<PType> & P);
}
#ifndef IGL_STATIC_LIBRARY
# include "bfs.cpp"
#endif
#endif