@@ -4,21 +4,54 @@ Graph Container Interface
44Generic algorithms and views in this library require that your graph container
55is represented as an [ adjacency list] ( https://en.wikipedia.org/wiki/Adjacency_list ) .
66Your container is never accessed directly. Instead, the access is performed via the
7- * graph container interface* .
7+ * graph container interface* (GCI) .
88
99
1010``` c++
11- std::vector<std::vector<int >> g { //
12- /* 0* / {1}, //
13- /* 1* / {0} // (0) ----- (1)
14- };
11+ std::vector<std::vector<int >> g { //
12+ /*0*/ {1}, //
13+ /*1*/ {0} // (0) ----- (1)
14+ }; //
1515
16- auto && vtcs = graph::vertices(g); // get the std::range representing vertices
16+ auto && vtcs = graph::vertices(g); // get the std::range representing graph vertices
17+
1718 auto vit = std::ranges::begin(vtcs);
18- int id0 = graph::vertex_id(g, vit); // get the id of the vertex
19+
20+ int id0 = graph::vertex_id(g, vit); // get the id of the vertex
1921 assert (id0 == 0);
20- auto && edgs = graph::edges(g, * vit); //
22+
23+ auto && edgs = graph::edges(g, * vit); // get the std::range representing the neighbors of the vertex
24+
2125 auto eit = std::ranges::begin(edgs);
22- int id1 = graph::target_id(g, * eit);
26+
27+ int id1 = graph::target_id(g, * eit); // get the id of the vertex on the other side of the edge
2328 assert (id1 == 1);
24- ```
29+
30+ auto wit = graph::find_vertex(g, id1); // get iterator to vertex based on the vertex id
31+
32+ int id1_ = graph::vertex_id(g, wit);
33+ assert (id1_ == 1);
34+ ```
35+
36+ This set of operations may seem too rich: you need fewer operations to achieve the same
37+ for type `vector<vector<int>>`. But the Graph Container Interface needs to be prepared for
38+ very different representations of an adjacency list.
39+
40+ The list of all CPOs in the Graph Container interface is bigger.
41+ All the customization points are described in detail in section [Customization Points](../reference/customization_points.md).
42+
43+
44+ Testing the customization
45+ -------------------------
46+
47+ In order to test if your type has the necessary customization for all the CPOs, you can use concepts defined in this library.
48+
49+ The one that you will need most often is `graph::index_adjacency_list`:
50+
51+ ```c++
52+ #include <graph/graph.hpp>
53+
54+ static_assert(graph::index_adjacency_list<MyType>);
55+ ```
56+
57+ In practice, you need to customize only a handful of CPOs. Most of the others have their default customizaiton.
0 commit comments