adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>
enum { A, B, C, D, E, F, N }; const char* name = "ABCDEF"; typedef boost::adjacency_matrix<boost::directedS> Graph; Graph g(N); add_edge(B, C, g); add_edge(B, F, g); add_edge(C, A, g); add_edge(C, C, g); add_edge(D, E, g); add_edge(E, D, g); add_edge(F, A, g); std::cout << "vertex set: "; boost::print_vertices(g, name); std::cout << std::endl; std::cout << "edge set: "; boost::print_edges(g, name); std::cout << std::endl; std::cout << "out-edges: " << std::endl; boost::print_graph(g, name); std::cout << std::endl;输出为
vertex set: A B C D E F edge set: (B,C) (B,F) (C,A) (C,C) (D,E) (E,D) (F,A) out-edges: A --> B --> C F C --> A C D --> E E --> D F --> A创建 图 2 的图。
enum { A, B, C, D, E, F, N }; const char* name = "ABCDEF"; typedef boost::adjacency_matrix<boost::undirectedS> UGraph; UGraph ug(N); add_edge(B, C, ug); add_edge(B, F, ug); add_edge(C, A, ug); add_edge(D, E, ug); add_edge(F, A, ug); std::cout << "vertex set: "; boost::print_vertices(ug, name); std::cout << std::endl; std::cout << "edge set: "; boost::print_edges(ug, name); std::cout << std::endl; std::cout << "incident edges: " << std::endl; boost::print_graph(ug, name); std::cout << std::endl;输出为
vertex set: A B C D E F edge set: (C,A) (C,B) (E,D) (F,A) (F,B) incident edges: A <--> C F B <--> C F C <--> A B D <--> E E <--> D F <--> A B
参数 | 描述 | 默认值 |
---|---|---|
Directed | 用于选择图是有向还是无向的选择器。选项是directedS和undirectedS. | directedS |
VertexProperty | 用于指定内部属性存储。 | no_property |
EdgeProperty | 用于指定内部属性存储。 | no_property |
GraphProperty | 用于指定图对象的属性存储。 | no_property |
adjacency_matrix(vertices_size_type n, const GraphProperty& p = GraphProperty())创建具有n个顶点和零条边的图对象。
template <typename EdgeIterator> adjacency_matrix(EdgeIterator first, EdgeIterator last, vertices_size_type n, const GraphProperty& p = GraphProperty())创建具有n创建具有n个顶点的图,其边在范围[first, last)给出的边列表中指定。`EdgeIterator` 的 `value_type` 必须是 `std::pair`,其中 pair 中的类型是整数类型。整数将对应于顶点,并且它们必须全部落在.
template <typename EdgeIterator, typename EdgePropertyIterator> adjacency_matrix(EdgeIterator first, EdgeIterator last, EdgePropertyIterator ep_iter, vertices_size_type n, const GraphProperty& p = GraphProperty())创建具有n的范围内。(迭代器可构造图 要求。)n个顶点的图,其边在范围[first, last)给出的边列表中指定。`EdgeIterator` 的 `value_type` 必须是 `std::pair`,其中 pair 中的类型是整数类型。整数将对应于顶点,并且它们必须全部落在创建具有n个顶点的图,其边在范围 `[first, last)` 给出的边列表中指定。`ep_iter` 的 `value_type应该是EdgeProperty.
std::pair<vertex_iterator, vertex_iterator> vertices(const adjacency_matrix& g)返回一个迭代器范围,提供对图g.
std::pair<edge_iterator, edge_iterator> edges(const adjacency_matrix& g);gg.
std::pair<adjacency_iterator, adjacency_iterator> adjacent_vertices(vertex_descriptor v, const adjacency_matrix& g)的边集的访问。v相邻的顶点的访问。g.
std::pair<out_edge_iterator, out_edge_iterator> out_edges(vertex_descriptor v, const adjacency_matrix& g)返回一个迭代器范围,提供对顶点v相邻的顶点的访问。guv.
vertex_descriptor source(edge_descriptor e, const adjacency_matrix& g)关联的所有边的访问。返回边.
vertex_descriptor target(edge_descriptor e, const adjacency_matrix& g)e返回边.
degree_size_type out_degree(vertex_descriptor u, const adjacency_matrix& g)返回离开顶点u.
std::pair<in_edge_iterator, in_edge_iterator> in_edges(vertex_descriptor v, const adjacency_matrix& g)返回一个迭代器范围,提供对顶点v相邻的顶点的访问。guv.
degree_size_type in_degree(vertex_descriptor u, const adjacency_matrix& g)返回进入顶点u.
vertices_size_type num_vertices(const adjacency_matrix& g)返回图中的顶点数。g.
edges_size_type num_edges(const adjacency_matrix& g)返回图中的边数。g.
vertex_descriptor vertex(vertices_size_type n, const adjacency_matrix& g)返回图的顶点列表中的第 n 个顶点。
std::pair<edge_descriptor, bool> edge(vertex_descriptor u, vertex_descriptor v, const adjacency_matrix& g)返回连接顶点uuv相邻的顶点的访问。g.
std::pair<edge_descriptor, bool> add_edge(vertex_descriptor u, vertex_descriptor v, adjacency_matrix& g)将边(u,v)添加到图中,并返回新边的边描述符。如果边已在图中,则不会添加重复边,并且bool标志将为false。此操作不会使图的任何迭代器或描述符失效。
std::pair<edge_descriptor, bool> add_edge(vertex_descriptor u, vertex_descriptor v, const EdgeProperty& p, adjacency_matrix& g)将边(u,v)将边添加到图中,并将p附加为边内部属性存储的值。另请参阅前面的add_edge()
void remove_edge(vertex_descriptor u, vertex_descriptor v, adjacency_matrix& g)从图中移除边(u,v)。
void remove_edge(edge_descriptor e, adjacency_matrix& g)从图中移除边返回边从图中移除边。这等效于调用.
void clear_vertex(vertex_descriptor u, adjacency_matrix& g)移除所有与顶点u相连的边。顶点仍然出现在图的顶点集中。
template <typename Property> property_map<adjacency_matrix, Property>::type get(Property, adjacency_matrix& g) template <typename Property> property_map<adjacency_matrix, Property>::const_type get(Property, const adjacency_matrix& g)返回由Property创建具有Property指定的顶点属性的属性映射对象。`VertexPropertyVertexProperty` 模板参数中指定的属性之一匹配。
template <typename Property, typename X> typename property_traits< typename property_map<adjacency_matrix, Property>::const_type >::value_type get(Property, const adjacency_matrix& g, X x)这将返回x` 是顶点或边描述符。`的属性值,它是顶点或边描述符。
template <typename Property, typename X, typename Value> void put(Property, const adjacency_matrix& g, X x, const Value& value)这会将x` 是顶点或边描述符。`的属性值设置为value. x` 是顶点或边描述符。`。`Value必须可转换为 `typename property_traits<property_map<adjacency_matrix, Property>::type>::value_type`。.
template <typename GraphProperty, typename GraphProperty> typename property_value<GraphProperty, GraphProperty>::type& get_property(adjacency_matrix& g, GraphProperty)返回附加到图对象GraphProperty的由g创建具有指定的属性。`property_traits` 类在boost/pending/property.hpp.
template <typename GraphProperty, typename GraphProperty> const typename property_value<GraphProperty, GraphProperty>::type& get_property(const adjacency_matrix& g, GraphProperty)返回附加到图对象GraphProperty的由g创建具有指定的属性。`property_traits` 类在boost/pending/property.hpp.