1 // (C) Copyright 2007-2009 Andrew Sutton
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0 (See accompanying file
5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_GRAPH_UNDIRECTED_GRAPH_HPP
8 #define BOOST_GRAPH_UNDIRECTED_GRAPH_HPP
10 #include <boost/graph/adjacency_list.hpp>
11 #include <boost/graph/properties.hpp>
12 #include <boost/pending/property.hpp>
13 #include <boost/property_map/transform_value_property_map.hpp>
14 #include <boost/type_traits.hpp>
15 #include <boost/mpl/if.hpp>
19 struct undirected_graph_tag
24 * The undirected_graph class template is a simplified version of the BGL
25 * adjacency list. This class is provided for ease of use, but may not
26 * perform as well as custom-defined adjacency list classes. Instances of
27 * this template model the VertexIndexGraph, and EdgeIndexGraph concepts. The
28 * graph is also fully mutable, supporting both insertions and removals of
31 * @note Special care must be taken when removing vertices or edges since
32 * those operations can invalidate the numbering of vertices.
34 template < typename VertexProp = no_property, typename EdgeProp = no_property,
35 typename GraphProp = no_property >
36 class undirected_graph
39 typedef GraphProp graph_property_type;
40 typedef VertexProp vertex_property_type;
41 typedef EdgeProp edge_property_type;
42 typedef typename lookup_one_property< GraphProp, graph_bundle_t >::type
44 typedef typename lookup_one_property< VertexProp, vertex_bundle_t >::type
46 typedef typename lookup_one_property< EdgeProp, edge_bundle_t >::type
50 // Embed indices into the vertex type.
51 typedef property< vertex_index_t, unsigned, vertex_property_type >
52 internal_vertex_property;
53 typedef property< edge_index_t, unsigned, edge_property_type >
54 internal_edge_property;
57 typedef adjacency_list< listS, listS, undirectedS, internal_vertex_property,
58 internal_edge_property, GraphProp, listS >
63 typedef typename graph_type::vertex_list_selector vertex_list_selector;
64 typedef typename graph_type::edge_list_selector edge_list_selector;
65 typedef typename graph_type::out_edge_list_selector out_edge_list_selector;
66 typedef typename graph_type::directed_selector directed_selector;
69 // more commonly used graph types
70 typedef typename graph_type::stored_vertex stored_vertex;
71 typedef typename graph_type::vertices_size_type vertices_size_type;
72 typedef typename graph_type::edges_size_type edges_size_type;
73 typedef typename graph_type::degree_size_type degree_size_type;
74 typedef typename graph_type::vertex_descriptor vertex_descriptor;
75 typedef typename graph_type::edge_descriptor edge_descriptor;
78 typedef typename graph_type::vertex_iterator vertex_iterator;
79 typedef typename graph_type::edge_iterator edge_iterator;
80 typedef typename graph_type::out_edge_iterator out_edge_iterator;
81 typedef typename graph_type::in_edge_iterator in_edge_iterator;
82 typedef typename graph_type::adjacency_iterator adjacency_iterator;
84 // miscellaneous types
85 typedef undirected_graph_tag graph_tag;
86 typedef typename graph_type::directed_category directed_category;
87 typedef typename graph_type::edge_parallel_category edge_parallel_category;
88 typedef typename graph_type::traversal_category traversal_category;
90 typedef std::size_t vertex_index_type;
91 typedef std::size_t edge_index_type;
93 inline undirected_graph(GraphProp const& p = GraphProp())
97 , m_max_vertex_index(0)
102 inline undirected_graph(undirected_graph const& x)
104 , m_num_vertices(x.m_num_vertices)
105 , m_num_edges(x.m_num_edges)
106 , m_max_vertex_index(x.m_max_vertex_index)
107 , m_max_edge_index(x.m_max_edge_index)
111 inline undirected_graph(
112 vertices_size_type n, GraphProp const& p = GraphProp())
116 , m_max_vertex_index(n)
117 , m_max_edge_index(0)
119 renumber_vertex_indices();
122 template < typename EdgeIterator >
123 inline undirected_graph(EdgeIterator f, EdgeIterator l,
124 vertices_size_type n, edges_size_type m = 0,
125 GraphProp const& p = GraphProp())
126 : m_graph(f, l, n, m, p)
129 , m_max_vertex_index(n)
130 , m_max_edge_index(0)
132 // Unfortunately, we have to renumber to ensure correct indexing.
135 // Can't always guarantee that the number of edges is actually
136 // m if distance(f, l) != m (or is undefined).
137 m_num_edges = m_max_edge_index = boost::num_edges(m_graph);
140 undirected_graph& operator=(undirected_graph const& g)
145 m_num_vertices = g.m_num_vertices;
146 m_num_edges = g.m_num_edges;
147 m_max_vertex_index = g.m_max_vertex_index;
152 // The impl_() methods are not part of the public interface.
153 graph_type& impl() { return m_graph; }
155 graph_type const& impl() const { return m_graph; }
157 // The following methods are not part of the public interface
158 vertices_size_type num_vertices() const { return m_num_vertices; }
161 // This helper function manages the attribution of vertex indices.
162 vertex_descriptor make_index(vertex_descriptor v)
164 boost::put(vertex_index, m_graph, v, m_max_vertex_index);
166 m_max_vertex_index++;
171 vertex_descriptor add_vertex()
173 return make_index(boost::add_vertex(m_graph));
176 vertex_descriptor add_vertex(vertex_property_type const& p)
179 boost::add_vertex(internal_vertex_property(0u, p), m_graph));
182 void clear_vertex(vertex_descriptor v)
184 std::pair< out_edge_iterator, out_edge_iterator > p
185 = boost::out_edges(v, m_graph);
186 m_num_edges -= std::distance(p.first, p.second);
187 boost::clear_vertex(v, m_graph);
190 void remove_vertex(vertex_descriptor v)
192 boost::remove_vertex(v, m_graph);
196 edges_size_type num_edges() const { return m_num_edges; }
199 // A helper fucntion for managing edge index attributes.
200 std::pair< edge_descriptor, bool > const& make_index(
201 std::pair< edge_descriptor, bool > const& x)
205 boost::put(edge_index, m_graph, x.first, m_max_edge_index);
213 std::pair< edge_descriptor, bool > add_edge(
214 vertex_descriptor u, vertex_descriptor v)
216 return make_index(boost::add_edge(u, v, m_graph));
219 std::pair< edge_descriptor, bool > add_edge(
220 vertex_descriptor u, vertex_descriptor v, edge_property_type const& p)
223 boost::add_edge(u, v, internal_edge_property(0u, p), m_graph));
226 void remove_edge(vertex_descriptor u, vertex_descriptor v)
228 // find all edges, (u, v)
229 std::vector< edge_descriptor > edges;
230 out_edge_iterator i, i_end;
231 for (boost::tie(i, i_end) = boost::out_edges(u, m_graph); i != i_end;
234 if (boost::target(*i, m_graph) == v)
239 // remove all edges, (u, v)
240 typename std::vector< edge_descriptor >::iterator j = edges.begin(),
242 for (; j != j_end; ++j)
248 void remove_edge(edge_iterator i) { remove_edge(*i); }
250 void remove_edge(edge_descriptor e)
252 boost::remove_edge(e, m_graph);
256 vertex_index_type max_vertex_index() const { return m_max_vertex_index; }
258 void renumber_vertex_indices()
260 vertex_iterator i, i_end;
261 boost::tie(i, i_end) = vertices(m_graph);
262 m_max_vertex_index = renumber_vertex_indices(i, i_end, 0);
265 void remove_vertex_and_renumber_indices(vertex_iterator i)
267 vertex_iterator j = next(i), end = vertices(m_graph).second;
268 vertex_index_type n = get(vertex_index, m_graph, *i);
270 // remove the offending vertex and renumber everything after
272 m_max_vertex_index = renumber_vertex_indices(j, end, n);
275 edge_index_type max_edge_index() const { return m_max_edge_index; }
277 void renumber_edge_indices()
279 edge_iterator i, end;
280 boost::tie(i, end) = edges(m_graph);
281 m_max_edge_index = renumber_edge_indices(i, end, 0);
284 void remove_edge_and_renumber_indices(edge_iterator i)
286 edge_iterator j = next(i), end = edges(m_graph.second);
287 edge_index_type n = get(edge_index, m_graph, *i);
289 // remove the edge and renumber everything after it
291 m_max_edge_index = renumber_edge_indices(j, end, n);
294 void renumber_indices()
296 renumber_vertex_indices();
297 renumber_edge_indices();
300 // bundled property support
301 #ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
302 vertex_bundled& operator[](vertex_descriptor v) { return m_graph[v]; }
304 vertex_bundled const& operator[](vertex_descriptor v) const
309 edge_bundled& operator[](edge_descriptor e) { return m_graph[e]; }
311 edge_bundled const& operator[](edge_descriptor e) const
316 graph_bundled& operator[](graph_bundle_t) { return get_property(*this); }
318 graph_bundled const& operator[](graph_bundle_t) const
320 return get_property(*this);
325 static vertex_descriptor null_vertex() { return graph_type::null_vertex(); }
330 m_num_vertices = m_max_vertex_index = 0;
331 m_num_edges = m_max_edge_index = 0;
334 void swap(undirected_graph& g)
336 m_graph.swap(g.m_graph);
337 std::swap(m_num_vertices, g.m_num_vertices);
338 std::swap(m_max_vertex_index, g.m_max_vertex_index);
339 std::swap(m_num_edges, g.m_num_edges);
340 std::swap(m_max_edge_index, g.m_max_edge_index);
344 vertices_size_type renumber_vertex_indices(
345 vertex_iterator i, vertex_iterator end, vertices_size_type n)
348 typename property_map< graph_type, vertex_index_t >::type IndexMap;
349 IndexMap indices = get(vertex_index, m_graph);
350 for (; i != end; ++i)
357 edges_size_type renumber_edge_indices(
358 edge_iterator i, edge_iterator end, edges_size_type n)
361 typename property_map< graph_type, edge_index_t >::type IndexMap;
362 IndexMap indices = get(edge_index, m_graph);
363 for (; i != end; ++i)
371 vertices_size_type m_num_vertices;
372 edges_size_type m_num_edges;
373 vertex_index_type m_max_vertex_index;
374 edge_index_type m_max_edge_index;
377 #define UNDIRECTED_GRAPH_PARAMS typename VP, typename EP, typename GP
378 #define UNDIRECTED_GRAPH undirected_graph< VP, EP, GP >
380 // IncidenceGraph concepts
381 template < UNDIRECTED_GRAPH_PARAMS >
382 inline typename UNDIRECTED_GRAPH::vertex_descriptor source(
383 typename UNDIRECTED_GRAPH::edge_descriptor e, UNDIRECTED_GRAPH const& g)
385 return source(e, g.impl());
388 template < UNDIRECTED_GRAPH_PARAMS >
389 inline typename UNDIRECTED_GRAPH::vertex_descriptor target(
390 typename UNDIRECTED_GRAPH::edge_descriptor e, UNDIRECTED_GRAPH const& g)
392 return target(e, g.impl());
395 template < UNDIRECTED_GRAPH_PARAMS >
396 inline typename UNDIRECTED_GRAPH::degree_size_type out_degree(
397 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
399 return out_degree(v, g.impl());
402 template < UNDIRECTED_GRAPH_PARAMS >
403 inline std::pair< typename UNDIRECTED_GRAPH::out_edge_iterator,
404 typename UNDIRECTED_GRAPH::out_edge_iterator >
406 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
408 return out_edges(v, g.impl());
411 // BidirectionalGraph concepts
412 template < UNDIRECTED_GRAPH_PARAMS >
413 inline typename UNDIRECTED_GRAPH::degree_size_type in_degree(
414 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
416 return in_degree(v, g.impl());
419 template < UNDIRECTED_GRAPH_PARAMS >
420 inline std::pair< typename UNDIRECTED_GRAPH::in_edge_iterator,
421 typename UNDIRECTED_GRAPH::in_edge_iterator >
423 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
425 return in_edges(v, g.impl());
428 template < UNDIRECTED_GRAPH_PARAMS >
429 inline std::pair< typename UNDIRECTED_GRAPH::out_edge_iterator,
430 typename UNDIRECTED_GRAPH::out_edge_iterator >
432 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
434 return out_edges(v, g.impl());
437 template < UNDIRECTED_GRAPH_PARAMS >
438 inline typename UNDIRECTED_GRAPH::degree_size_type degree(
439 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
441 return degree(v, g.impl());
444 // AdjacencyGraph concepts
445 template < UNDIRECTED_GRAPH_PARAMS >
446 inline std::pair< typename UNDIRECTED_GRAPH::adjacency_iterator,
447 typename UNDIRECTED_GRAPH::adjacency_iterator >
449 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
451 return adjacent_vertices(v, g.impl());
454 template < UNDIRECTED_GRAPH_PARAMS >
455 typename UNDIRECTED_GRAPH::vertex_descriptor vertex(
456 typename UNDIRECTED_GRAPH::vertices_size_type n, UNDIRECTED_GRAPH const& g)
458 return vertex(n, g.impl());
461 template < UNDIRECTED_GRAPH_PARAMS >
462 std::pair< typename UNDIRECTED_GRAPH::edge_descriptor, bool > edge(
463 typename UNDIRECTED_GRAPH::vertex_descriptor u,
464 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
466 return edge(u, v, g.impl());
469 // VertexListGraph concepts
470 template < UNDIRECTED_GRAPH_PARAMS >
471 inline typename UNDIRECTED_GRAPH::vertices_size_type num_vertices(
472 UNDIRECTED_GRAPH const& g)
474 return g.num_vertices();
477 template < UNDIRECTED_GRAPH_PARAMS >
478 inline std::pair< typename UNDIRECTED_GRAPH::vertex_iterator,
479 typename UNDIRECTED_GRAPH::vertex_iterator >
480 vertices(UNDIRECTED_GRAPH const& g)
482 return vertices(g.impl());
485 // EdgeListGraph concepts
486 template < UNDIRECTED_GRAPH_PARAMS >
487 inline typename UNDIRECTED_GRAPH::edges_size_type num_edges(
488 UNDIRECTED_GRAPH const& g)
490 return g.num_edges();
493 template < UNDIRECTED_GRAPH_PARAMS >
494 inline std::pair< typename UNDIRECTED_GRAPH::edge_iterator,
495 typename UNDIRECTED_GRAPH::edge_iterator >
496 edges(UNDIRECTED_GRAPH const& g)
498 return edges(g.impl());
501 // MutableGraph concepts
502 template < UNDIRECTED_GRAPH_PARAMS >
503 inline typename UNDIRECTED_GRAPH::vertex_descriptor add_vertex(
506 return g.add_vertex();
509 template < UNDIRECTED_GRAPH_PARAMS >
510 inline typename UNDIRECTED_GRAPH::vertex_descriptor add_vertex(
511 typename UNDIRECTED_GRAPH::vertex_property_type const& p,
514 return g.add_vertex(p);
517 template < UNDIRECTED_GRAPH_PARAMS >
518 inline void clear_vertex(
519 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH& g)
521 return g.clear_vertex(v);
524 template < UNDIRECTED_GRAPH_PARAMS >
525 inline void remove_vertex(
526 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH& g)
528 return g.remove_vertex(v);
531 template < UNDIRECTED_GRAPH_PARAMS >
532 inline std::pair< typename UNDIRECTED_GRAPH::edge_descriptor, bool > add_edge(
533 typename UNDIRECTED_GRAPH::vertex_descriptor u,
534 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH& g)
536 return g.add_edge(u, v);
539 template < UNDIRECTED_GRAPH_PARAMS >
540 inline std::pair< typename UNDIRECTED_GRAPH::edge_descriptor, bool > add_edge(
541 typename UNDIRECTED_GRAPH::vertex_descriptor u,
542 typename UNDIRECTED_GRAPH::vertex_descriptor v,
543 typename UNDIRECTED_GRAPH::edge_property_type const& p, UNDIRECTED_GRAPH& g)
545 return g.add_edge(u, v, p);
548 template < UNDIRECTED_GRAPH_PARAMS >
549 inline void remove_edge(typename UNDIRECTED_GRAPH::vertex_descriptor u,
550 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH& g)
552 return g.remove_edge(u, v);
555 template < UNDIRECTED_GRAPH_PARAMS >
556 inline void remove_edge(
557 typename UNDIRECTED_GRAPH::edge_descriptor e, UNDIRECTED_GRAPH& g)
559 return g.remove_edge(e);
562 template < UNDIRECTED_GRAPH_PARAMS >
563 inline void remove_edge(
564 typename UNDIRECTED_GRAPH::edge_iterator i, UNDIRECTED_GRAPH& g)
566 return g.remove_edge(i);
569 template < UNDIRECTED_GRAPH_PARAMS, class Predicate >
570 inline void remove_edge_if(Predicate pred, UNDIRECTED_GRAPH& g)
572 return remove_edge_if(pred, g.impl());
575 template < UNDIRECTED_GRAPH_PARAMS, class Predicate >
576 inline void remove_incident_edge_if(
577 typename UNDIRECTED_GRAPH::vertex_descriptor v, Predicate pred,
580 return remove_out_edge_if(v, pred, g.impl());
583 template < UNDIRECTED_GRAPH_PARAMS, class Predicate >
584 inline void remove_out_edge_if(typename UNDIRECTED_GRAPH::vertex_descriptor v,
585 Predicate pred, UNDIRECTED_GRAPH& g)
587 return remove_out_edge_if(v, pred, g.impl());
590 template < UNDIRECTED_GRAPH_PARAMS, class Predicate >
591 inline void remove_in_edge_if(typename UNDIRECTED_GRAPH::vertex_descriptor v,
592 Predicate pred, UNDIRECTED_GRAPH& g)
594 return remove_in_edge_if(v, pred, g.impl());
597 template < UNDIRECTED_GRAPH_PARAMS, typename Property >
598 struct property_map< UNDIRECTED_GRAPH, Property >
599 : property_map< typename UNDIRECTED_GRAPH::graph_type, Property >
603 template < UNDIRECTED_GRAPH_PARAMS >
604 struct property_map< UNDIRECTED_GRAPH, vertex_all_t >
606 typedef transform_value_property_map< detail::remove_first_property,
607 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
608 vertex_all_t >::const_type >
610 typedef transform_value_property_map< detail::remove_first_property,
611 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
612 vertex_all_t >::type >
616 template < UNDIRECTED_GRAPH_PARAMS >
617 struct property_map< UNDIRECTED_GRAPH, edge_all_t >
619 typedef transform_value_property_map< detail::remove_first_property,
620 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
621 edge_all_t >::const_type >
623 typedef transform_value_property_map< detail::remove_first_property,
624 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
629 // PropertyGraph concepts
630 template < UNDIRECTED_GRAPH_PARAMS, typename Property >
631 inline typename property_map< UNDIRECTED_GRAPH, Property >::type get(
632 Property p, UNDIRECTED_GRAPH& g)
634 return get(p, g.impl());
637 template < UNDIRECTED_GRAPH_PARAMS, typename Property >
638 inline typename property_map< UNDIRECTED_GRAPH, Property >::const_type get(
639 Property p, UNDIRECTED_GRAPH const& g)
641 return get(p, g.impl());
644 template < UNDIRECTED_GRAPH_PARAMS >
645 inline typename property_map< UNDIRECTED_GRAPH, vertex_all_t >::type get(
646 vertex_all_t, UNDIRECTED_GRAPH& g)
648 return typename property_map< UNDIRECTED_GRAPH, vertex_all_t >::type(
649 detail::remove_first_property(), get(vertex_all, g.impl()));
652 template < UNDIRECTED_GRAPH_PARAMS >
653 inline typename property_map< UNDIRECTED_GRAPH, vertex_all_t >::const_type get(
654 vertex_all_t, UNDIRECTED_GRAPH const& g)
656 return typename property_map< UNDIRECTED_GRAPH, vertex_all_t >::const_type(
657 detail::remove_first_property(), get(vertex_all, g.impl()));
660 template < UNDIRECTED_GRAPH_PARAMS >
661 inline typename property_map< UNDIRECTED_GRAPH, edge_all_t >::type get(
662 edge_all_t, UNDIRECTED_GRAPH& g)
664 return typename property_map< UNDIRECTED_GRAPH, edge_all_t >::type(
665 detail::remove_first_property(), get(edge_all, g.impl()));
668 template < UNDIRECTED_GRAPH_PARAMS >
669 inline typename property_map< UNDIRECTED_GRAPH, edge_all_t >::const_type get(
670 edge_all_t, UNDIRECTED_GRAPH const& g)
672 return typename property_map< UNDIRECTED_GRAPH, edge_all_t >::const_type(
673 detail::remove_first_property(), get(edge_all, g.impl()));
676 template < UNDIRECTED_GRAPH_PARAMS, typename Property, typename Key >
677 inline typename property_traits< typename property_map<
678 typename UNDIRECTED_GRAPH::graph_type, Property >::const_type >::value_type
679 get(Property p, UNDIRECTED_GRAPH const& g, Key const& k)
681 return get(p, g.impl(), k);
684 template < UNDIRECTED_GRAPH_PARAMS, typename Key >
685 inline typename property_traits<
686 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
687 vertex_all_t >::const_type >::value_type
688 get(vertex_all_t, UNDIRECTED_GRAPH const& g, Key const& k)
690 return get(vertex_all, g.impl(), k).m_base;
693 template < UNDIRECTED_GRAPH_PARAMS, typename Key >
694 inline typename property_traits<
695 typename property_map< typename UNDIRECTED_GRAPH::graph_type,
696 edge_all_t >::const_type >::value_type
697 get(edge_all_t, UNDIRECTED_GRAPH const& g, Key const& k)
699 return get(edge_all, g.impl(), k).m_base;
702 template < UNDIRECTED_GRAPH_PARAMS, typename Property, typename Key,
704 inline void put(Property p, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
706 put(p, g.impl(), k, v);
709 template < UNDIRECTED_GRAPH_PARAMS, typename Key, typename Value >
710 inline void put(vertex_all_t, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
712 put(vertex_all, g.impl(), k,
713 typename UNDIRECTED_GRAPH::internal_vertex_property(
714 get(vertex_index, g.impl(), k), v));
717 template < UNDIRECTED_GRAPH_PARAMS, typename Key, typename Value >
718 inline void put(edge_all_t, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
720 put(edge_all, g.impl(), k,
721 typename UNDIRECTED_GRAPH::internal_vertex_property(
722 get(edge_index, g.impl(), k), v));
725 template < UNDIRECTED_GRAPH_PARAMS, class Property >
726 inline typename graph_property< UNDIRECTED_GRAPH, Property >::type&
727 get_property(UNDIRECTED_GRAPH& g, Property p)
729 return get_property(g.impl(), p);
732 template < UNDIRECTED_GRAPH_PARAMS, class Property >
733 inline typename graph_property< UNDIRECTED_GRAPH, Property >::type const&
734 get_property(UNDIRECTED_GRAPH const& g, Property p)
736 return get_property(g.impl(), p);
739 template < UNDIRECTED_GRAPH_PARAMS, class Property, class Value >
740 inline void set_property(UNDIRECTED_GRAPH& g, Property p, Value v)
742 return set_property(g.impl(), p, v);
745 // Indexed Vertex graph
747 template < UNDIRECTED_GRAPH_PARAMS >
748 inline typename UNDIRECTED_GRAPH::vertex_index_type get_vertex_index(
749 typename UNDIRECTED_GRAPH::vertex_descriptor v, UNDIRECTED_GRAPH const& g)
751 return get(vertex_index, g, v);
754 template < UNDIRECTED_GRAPH_PARAMS >
755 typename UNDIRECTED_GRAPH::vertex_index_type max_vertex_index(
756 UNDIRECTED_GRAPH const& g)
758 return g.max_vertex_index();
761 template < UNDIRECTED_GRAPH_PARAMS >
762 inline void renumber_vertex_indices(UNDIRECTED_GRAPH& g)
764 g.renumber_vertex_indices();
767 template < UNDIRECTED_GRAPH_PARAMS >
768 inline void remove_vertex_and_renumber_indices(
769 typename UNDIRECTED_GRAPH::vertex_iterator i, UNDIRECTED_GRAPH& g)
771 g.remove_vertex_and_renumber_indices(i);
774 // Edge index management
776 template < UNDIRECTED_GRAPH_PARAMS >
777 inline typename UNDIRECTED_GRAPH::edge_index_type get_edge_index(
778 typename UNDIRECTED_GRAPH::edge_descriptor v, UNDIRECTED_GRAPH const& g)
780 return get(edge_index, g, v);
783 template < UNDIRECTED_GRAPH_PARAMS >
784 typename UNDIRECTED_GRAPH::edge_index_type max_edge_index(
785 UNDIRECTED_GRAPH const& g)
787 return g.max_edge_index();
790 template < UNDIRECTED_GRAPH_PARAMS >
791 inline void renumber_edge_indices(UNDIRECTED_GRAPH& g)
793 g.renumber_edge_indices();
796 template < UNDIRECTED_GRAPH_PARAMS >
797 inline void remove_edge_and_renumber_indices(
798 typename UNDIRECTED_GRAPH::edge_iterator i, UNDIRECTED_GRAPH& g)
800 g.remove_edge_and_renumber_indices(i);
804 template < UNDIRECTED_GRAPH_PARAMS >
805 inline void renumber_indices(UNDIRECTED_GRAPH& g)
807 g.renumber_indices();
811 template < UNDIRECTED_GRAPH_PARAMS >
812 struct graph_mutability_traits< UNDIRECTED_GRAPH >
814 typedef mutable_property_graph_tag category;
817 #undef UNDIRECTED_GRAPH_PARAMS
818 #undef UNDIRECTED_GRAPH
820 } /* namespace boost */