We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4792e04 + d93f67d commit 9bed95cCopy full SHA for 9bed95c
example/bellman-ford-internet.cpp
@@ -25,19 +25,18 @@ int main()
25
H,
26
n_vertices
27
};
28
- const int n_edges = 11;
29
typedef std::pair< int, int > Edge;
30
31
// The list of connections between routers stored in an array.
32
- Edge edges[] = { Edge(A, B), Edge(A, C), Edge(B, D), Edge(B, E), Edge(C, E),
33
- Edge(C, F), Edge(D, H), Edge(D, E), Edge(E, H), Edge(F, G),
+ Edge edges[] = { Edge(A, B), Edge(A, C), Edge(B, D), Edge(B, E),
+ Edge(C, E), Edge(C, F), Edge(D, H), Edge(D, E), Edge(E, H), Edge(F, G),
34
Edge(G, H) };
35
36
// Specify the graph type and declare a graph object
37
typedef edge_list< Edge*, Edge, std::ptrdiff_t,
38
std::random_access_iterator_tag >
39
Graph;
40
- Graph g(edges, edges + n_edges);
+ Graph g(std::begin(edges), std::end(edges));
41
42
// The transmission delay values for each edge.
43
float delay[] = { 5.0, 1.0, 1.3, 3.0, 10.0, 2.0, 6.3, 0.4, 1.3, 1.2, 0.5 };
example/min_max_paths.cpp
@@ -52,8 +52,8 @@ int main(int, char*[])
52
const char name[] = "abcdef";
53
54
const int num_nodes = 6;
55
- E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4),
56
- E(4, 0), E(4, 1) };
+ const auto edges = { E(0, 2), E(1, 1), E(1, 3), E(1, 4), E(2, 1), E(2, 3),
+ E(3, 4), E(4, 0), E(4, 1) };
57
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 };
58
const int n_edges = sizeof(edges) / sizeof(E);
59
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
@@ -68,8 +68,8 @@ int main(int, char*[])
68
weightmap[e] = weights[j];
69
}
70
#else
71
- Graph G(edges, edges + n_edges, weights, num_nodes);
72
- auto weightmap = get(edge_weight, G);
+ Graph G(std::begin(edges), std::end(edges), weights, num_nodes);
+ auto = get(edge_weight, G);
73
#endif
74
75
std::vector< Vertex > p(num_vertices(G));
example/prim-example.cpp
@@ -18,7 +18,7 @@ int main()
18
19
typedef std::pair< int, int > E;
20
const int num_nodes = 5;
21
- E edges[]
+ const auto edges
22
= { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) };
23
int weights[] = { 1, 1, 2, 7, 3, 1, 1 };
24
@@ -32,7 +32,7 @@ int main()
- Graph g(edges, edges + sizeof(edges) / sizeof(E), weights, num_nodes);
+ Graph g(std::begin(edges), std::end(edges), weights, num_nodes);
std::vector< graph_traits< Graph >::vertex_descriptor > p(num_vertices(g));
example/remove_edge_if_dir.cpp
@@ -41,17 +41,10 @@ typedef adjacency_list< vecS, vecS, directedS > Graph;
int main()
{
typedef std::pair< std::size_t, std::size_t > Edge;
44
- Edge edges[6] = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3),
+ const auto edges = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3),
45
Edge(2, 0), Edge(3, 2) };
46
47
-#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
48
- // VC++ can't handle iterator constructor
49
- Graph g(4);
50
- for (std::size_t j = 0; j < 6; ++j)
51
- add_edge(edges[j].first, edges[j].second, g);
-#else
- Graph g(edges, edges + 6, 4);
-#endif
+ Graph g(std::begin(edges), std::end(edges), 4);
std::cout << "original graph:" << std::endl;
print_graph(g, get(vertex_index, g));
example/stoer_wagner.cpp
@@ -45,7 +45,7 @@ int main()
// construct the graph object. 8 is the number of vertices, which are
// numbered from 0 through 7, and 16 is the number of edges.
- undirected_graph g(edges, edges + 16, ws, 8, 16);
+ undirected_graph g(std::begin(edges), std::end(edges), ws, 8, 16);
// define a property map, `parities`, that will store a boolean value for
// each vertex. Vertices that have the same parity after
example/topo_sort.cpp
@@ -43,16 +43,10 @@ int main(int, char*[])
typedef boost::graph_traits< Graph >::vertex_descriptor Vertex;
- Pair edges[6] = { Pair(0, 1), Pair(2, 4), Pair(2, 5), Pair(0, 3),
+ const auto edges = { Pair(0, 1), Pair(2, 4), Pair(2, 5), Pair(0, 3),
Pair(1, 4), Pair(4, 3) };
- // VC++ can't handle the iterator constructor
- Graph G(6);
- add_edge(edges[j].first, edges[j].second, G);
- Graph G(edges, edges + 6, 6);
+
+ Graph G(std::begin(edges), std::end(edges), 6 /* vertices count */);
auto id = get(vertex_index, G);
example/visitor.cpp
@@ -71,15 +71,9 @@ int main(int, char*[])
typedef adjacency_list<> Graph;
- E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1), E(3, 4),
76
77
- Graph G(5);
78
- for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j)
79
80
81
- Graph G(edges, edges + sizeof(edges) / sizeof(E), 5);
82
+ const auto edges = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1),
+ Graph G(std::begin(edges), std::end(edges), 5);
83
84
typedef boost::graph_traits< Graph >::vertices_size_type size_type;
85
0 commit comments