|
| 1 | + |
| 2 | + |
| 3 | +* Versions of boost |
| 4 | + * github: https://github.com/boostorg/boost.git |
| 5 | + * github release: https://github.com/boostorg/boost/releases/tag/boost-1.90.0 (matches github directory structure) |
| 6 | + * boost.org: https://archives.boost.io/release/1.90.0/source/boost_1_90_0.tar.gz |
| 7 | + |
| 8 | +* We are using version cloned from github, following github README for bgl |
| 9 | + |
| 10 | +``` |
| 11 | +Development |
| 12 | +
|
| 13 | +Clone the whole boost project, which includes the individual Boost projects as submodules (see boost+git doc): |
| 14 | +
|
| 15 | +git clone https://github.com/boostorg/boost |
| 16 | +cd boost |
| 17 | +git submodule update --init |
| 18 | +The Boost Graph Library is located in libs/graph/. |
| 19 | +
|
| 20 | +Boost Graph Library is mostly made of headers but also contains some compiled components. Here are the build commands: |
| 21 | +
|
| 22 | +./bootstrap.sh <- compile b2 |
| 23 | +./b2 headers <- just installs headers |
| 24 | +./b2 <- build compiled components |
| 25 | +Note: The Boost Graph Library cannot currently be built outside of Boost itself. |
| 26 | +``` |
| 27 | + |
| 28 | +### Property maps |
| 29 | + |
| 30 | +Issue is that a vertex property can be stored in one of two ways.1990s |
| 31 | + |
| 32 | +Property may be stored in an external container, so that it is looked up as an indexing operation: |
| 33 | +``` |
| 34 | + std::vector<double> weights; |
| 35 | + weight = weights[v] |
| 36 | +``` |
| 37 | +Whereas a vertex property might be a field in a vertex object |
| 38 | +``` |
| 39 | + struct vertex { |
| 40 | + double weight; |
| 41 | + } |
| 42 | +``` |
| 43 | +Lookup is with |
| 44 | +``` |
| 45 | + weight = v.weight |
| 46 | +``` |
| 47 | +Property maps provide an abstraction so that an algorithm that needs properties can use uniform syntax, regardless |
| 48 | +of how properties are actually stored. Meaning |
| 49 | +``` |
| 50 | + weight = get(v, weights) |
| 51 | +``` |
| 52 | +will return the associated property, whether the property is storect in an external container, or as a member of an object. |
| 53 | + |
| 54 | +Currently, this abstraction requires a complicated use of preprocessor and so forth, we would like to be able to do something equivalent, but without using compliated preprocessor mechanisms. |
| 55 | +We would like to be able to write our algorithms with a single syntax for accessing a property, regardless how that property is related to a vertex associated with a graph. |
| 56 | +For example if we have |
| 57 | +``` |
| 58 | + using vertex_type = struct { |
| 59 | + size_t weight |
| 60 | + } |
| 61 | + using graph_type = struct { |
| 62 | + std::vector<vertex_type> vertices; |
| 63 | + } |
| 64 | +``` |
| 65 | +In a generic graph algorithm parameterized by graph type, we could invoke it as |
| 66 | +``` |
| 67 | + dijkstra(g, s) |
| 68 | +``` |
| 69 | +and dijkstra would use the weight member from the vertex structure when weight properties are needed in the algorithm. |
| 70 | +Alternatively, we might define weight properties as |
| 71 | +``` |
| 72 | + using weights_container = std::vector<size_t>; |
| 73 | + using vertex_type = size_t; |
| 74 | +``` |
| 75 | +and invoke generic dijkstra as |
| 76 | +``` |
| 77 | + weights_container weights; |
| 78 | + dijkstra(g, s, weights); |
| 79 | +``` |
| 80 | +In this case, the algorithm would access the weight property from the external container. |
| 81 | +However, since we want dijkstra to be a generic algorithm, we would like to be able to invoke it regardless of how properties are accessed. |
| 82 | +Also, since it is a generic algorithm, we need a single syntax in the algorithm for accessing properties, regardless of how they are stored. |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +### Named parameters |
| 87 | + |
| 88 | +Many algorithms require a large number of parameters, some of which are used, some not, some defaulted, in different contexts. |
| 89 | +For instance Dijkstras algorithm might take the graph, starting vertext, container for distances, for weights, for predecessors, etc, |
| 90 | +but in any particular use, we might only us a subset. In other languages, we could use named (or keyword) parameters such as |
| 91 | +``` |
| 92 | + dijkstra(g, s, distance=d, weights=w) |
| 93 | +``` |
| 94 | +and the predecessors would not be used. |
| 95 | +BGL does this by chaining members of a parameter object |
| 96 | +``` |
| 97 | + dijkstra(g, s, params.distance(d).weights(w)) |
| 98 | +``` |
| 99 | +where unused members are defaulted. The C++20 structure initialization should be a good alternative. |
0 commit comments