boost graph之基础

news2024/10/7 14:23:52

结构

在这里插入图片描述

属性相关

put_get_helper<Reference, LvaluePropertyMap>
iterator_property_map<RandomAccessIterator, IndexMap, T, R>
safe_iterator_property_map<RandomAccessIterator, IndexMap, T, R>
associative_property_map<UniquePairAssociativeContainer>
const_associative_property_map<UniquePairAssociativeContainer>
static_property_map<ValueType>
ref_property_map<KeyType, ValueType>
typed_identity_property_map<T>

图获取属性

//boost/graph/detail/adjacency_list.hpp
template <class Config, class Base, class Property>
    inline
    typename boost::property_map<typename Config::graph_type, Property>::type
    get(Property p, adj_list_helper<Config, Base>& g) {
      typedef typename detail::property_kind_from_graph<adj_list_helper<Config, Base>, Property>::type Kind;
      return detail::get_dispatch(g, p, Kind());
    }

template <class Config, class Base, class Property>
      inline
      typename boost::property_map<typename Config::graph_type,
        Property>::type
      get_dispatch(adj_list_helper<Config,Base>&, Property p,
                   boost::edge_property_tag) {
        typedef typename Config::graph_type Graph;
        typedef typename boost::property_map<Graph, Property>::type PA;
        return PA(p);
      }

通过get_dispatch作转发,调用具体的模板特例化实例
graph对于图这块专门定义了类property_map,用来表示图属性相关的,分为点属性edge_property_map和边属性vertex_property_map

template <class Graph, class Property, class Enable = void>
  struct property_map:
    mpl::if_<
      is_same<typename detail::property_kind_from_graph<Graph, Property>::type, edge_property_tag>,
      detail::edge_property_map<Graph, Property>,
      detail::vertex_property_map<Graph, Property> >::type
  {};

边属性

其依赖边属性选择器edge_property_selector,对于不同的图会特例化不同的边选择器

template <class Graph, class PropertyTag>
    struct edge_property_map
      : edge_property_selector<
          typename graph_tag_or_void<Graph>::type
        >::type::template bind_<
                            Graph,
                            typename edge_property_type<Graph>::type,
                            PropertyTag>
      {};

  template <class GraphTag>
  struct edge_property_selector {
    typedef detail::dummy_edge_property_selector type;
  };

对于邻接表,特例化为

template <>
  struct edge_property_selector<adj_list_tag> {
    typedef detail::adj_list_edge_property_selector type;
  };
  template <>
  struct edge_property_selector<vec_adj_list_tag> {
    typedef detail::adj_list_edge_property_selector type;
  };

对于边列表,特例化为

template <>
  struct edge_property_selector<edge_list_tag> {
    typedef edge_list_edge_property_selector type;
  };

  template <>
  struct edge_property_selector<edge_list_ra_tag> {
    typedef edge_list_ra_edge_property_selector type;
  };

对于图作为树,特例化为

template <>
  struct edge_property_selector<graph_as_tree_tag> {
    typedef detail::graph_as_tree_edge_property_selector type;
  };

标签图,特例化为

template <>
struct edge_property_selector<labeled_graph_class_tag> {
    typedef graph_detail::labeled_graph_edge_property_selector type;
};

子图,特例化为

template <>
struct edge_property_selector<subgraph_tag> {
    typedef detail::subgraph_property_generator type;
};

点属性

其依赖点属性选择器vertex_property_selector,对于不同的图会特例化不同的点选择器

template <class Graph, class PropertyTag>
    struct vertex_property_map
      : vertex_property_selector<
          typename graph_tag_or_void<Graph>::type
        >::type::template bind_<
                            Graph,
                            typename vertex_property_type<Graph>::type,
                            PropertyTag>
      {};

template <class GraphTag>
  struct vertex_property_selector {
    typedef detail::dummy_vertex_property_selector type;
  };

对于邻接表,特例化为

template <>
  struct vertex_property_selector<adj_list_tag> {
    typedef adj_list_vertex_property_selector type;
  };

  struct vec_adj_list_vertex_property_selector {
    template <class Graph, class Property, class Tag>
    struct bind_: detail::vec_adj_list_choose_vertex_pa<Tag,Graph,Property> {};
  };
  template <>
  struct vertex_property_selector<vec_adj_list_tag> {
    typedef vec_adj_list_vertex_property_selector type;
  };

对于图作为树,特例化为

template <>
  struct vertex_property_selector<graph_as_tree_tag> {
    typedef detail::graph_as_tree_vertex_property_selector type;
  };

标签图,特例化为

template <>
struct vertex_property_selector<labeled_graph_class_tag> {
    typedef graph_detail::labeled_graph_vertex_property_selector type;
};

子图,特例化

template <>
struct vertex_property_selector<subgraph_tag> {
    typedef detail::subgraph_property_generator type;
};

邻接表

adjacency_list
adj_list_gen
config
vec_adj_list_impl
adj_list_impl
adj_list_helper
directed_edges_helper
directed_graph_helper
undirected_graph_helper
bidirectional_graph_helper
bidirectional_graph_helper_with_property

adj_list_gen中定义了config类,以及vec_adj_list_impl,adj_list_impl,其中vec_adj_list_impl和adj_list_impl是if条件类型来区分
同时也定义了DirectedHelper,这个是通过mpl::if_的条件选型来决定是基类是使用bidirectional_graph_helper_with_property,还是directed_graph_helper或者undirected_graph_helper

list_edge
edge_base

edge_base:只包含顶点,没有其它的信息
list_edge:除了包含顶点信息,还包含边的辅助信息

边描述符

邻接表的边通过adjacency_list_traits定义

edge_desc_impl
edge_base

邻接表的点adjacency_list_traits中定义,如果支持随机访问时,类型为size_t,否则类型为void*

容器生成器

container_gen模板两个类型参数Selector和ValueType
Selector:表示所使用的容器类型,支持
● list
● vector
● map
● set
● multiset
● multimap
● hash_set
● hash_map
● hash_multiset
● hash_multimap
ValueType:表示容器中元素的类型
点的关连边表示所使用的就是container_gen,其值类型为StoredEdge,可能的值为
● stored_edge_property
● stored_ra_edge_iter
● stored_edge_iter

stored_edge
stored_edge_property
stored_edge_iter
stored_ra_edge_iter

点表示类型可以为
● stored_vertex
● vertex_ptr(void*)

stored_vertex
bidir_rand_stored_vertex
rand_stored_vertex
bidir_seq_stored_vertex
seq_stored_vertex

算法

基础

BFS

使用visitor模式,bfs visitor的必须支持以下方法
● initialize_vertex:算法开始时初始化点相关处理
● discover_vertex:发现点时处理
● examine_vertex:检查点处理
● examine_edge:检查边处理
● tree_edge:树边处理
● non_tree_edge:非树边处理
● gray_target:反向边处理
● black_target:前身边或者交叉边处理
● finish_vertex:点遍历完全时处理
bfs_visitor是bfs中其它visitor的代理,其模板类型参数表示代理的visitor类型

bfs_visitor<Visitors>
base_visitor<Visitor>
+operator()(T, Graph&)
null_visitor
dijkstra_visitor<Visitors>
+void edge_relaxed(Edge e, Graph& g)
+void edge_not_relaxed(Edge e, Graph& g)
astar_visitor
brandes_dijkstra_visitor
visitor_type
graph_copy_visitor
core_numbers_visitor
SAW_visitor
parallel_dijkstra_bfs_visitor
scc_discovery_visitor

DFS

dfs visitor的必须支持以下方法
● initialize_vertex
● start_vertex
● discover_vertex
● examine_edge
● tree_edge
● back_edge
● forward_or_cross_edge
● finish_vertex
● finish_edge

dfs_visitor<Visitors>
base_visitor<Visitor>
+operator()(T, Graph&)
null_visitor
topo_sort_visitor
biconnected_components_visitor
components_recorder
odd_components_counter
tarjan_scc_visitor
SAW_visitor
planar_dfs_visitor

最短路径

dijkstra_shortest_paths对于bgl_named_params会调用分发函数dijkstra_dispatch1

dijkstra_shortest_paths
    (const VertexListGraph& g,
     typename graph_traits<VertexListGraph>::vertex_descriptor s,
     const bgl_named_params<Param,Tag,Rest>& params)
-> 
dijkstra_dispatch1
      (const VertexListGraph& g,
       typename graph_traits<VertexListGraph>::vertex_descriptor s,
       DistanceMap distance, WeightMap weight, IndexMap index_map,
       const Params& params)
->
dijkstra_dispatch2
      (const VertexListGraph& g,
       typename graph_traits<VertexListGraph>::vertex_descriptor s,
       DistanceMap distance, WeightMap weight, IndexMap index_map,
       const Params& params)
->
dijkstra_shortest_paths
    (const VertexListGraph& g,
     typename graph_traits<VertexListGraph>::vertex_descriptor s,
     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis,
     const bgl_named_params<T, Tag, Base>&
     BOOST_GRAPH_ENABLE_IF_MODELS_PARM(VertexListGraph,vertex_list_graph_tag))
-> 
void
  dijkstra_shortest_paths
    (const VertexListGraph& g,
     SourceInputIter s_begin, SourceInputIter s_end,
     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis)
-> 
void
  dijkstra_shortest_paths
    (const VertexListGraph& g,
     SourceInputIter s_begin, SourceInputIter s_end,
     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis,
     const bgl_named_params<T, Tag, Base>&
     BOOST_GRAPH_ENABLE_IF_MODELS_PARM(VertexListGraph,vertex_list_graph_tag))
->
void
  dijkstra_shortest_paths
    (const VertexListGraph& g,
     SourceInputIter s_begin, SourceInputIter s_end,
     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis, ColorMap color)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1305724.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

文心一言 VS 讯飞星火 VS chatgpt (155)-- 算法导论12.3 2题

二、用go语言&#xff0c;假设通过反复向一棵树中插人互不相同的关键字来构造一棵二叉搜索树。证明&#xff1a;在这棵树中查找关键字所检查过的结点数目等于先前插入这个关键字所检查的结点数目加 1。 文心一言&#xff1a; 为了证明这个结论&#xff0c;我们可以使用二叉搜…

【代码随想录】刷题笔记Day34

前言 考过概率论&#xff0c;发过一场烧&#xff0c;兜兜转转又一月&#xff0c;轻舟已撞万重山&#xff0c;赶紧刷题 贪心算法理论基础 贪心的本质&#xff1a;局部最优→全局最优无套路&#xff0c;常识性推导 举反例 455. 分发饼干 - 力扣&#xff08;LeetCode&#xf…

Python (六) 绘图

程序员的公众号&#xff1a;源1024&#xff0c;获取更多资料&#xff0c;无加密无套路&#xff01; 最近整理了一波电子书籍资料&#xff0c;包含《Effective Java中文版 第2版》《深入JAVA虚拟机》&#xff0c;《重构改善既有代码设计》&#xff0c;《MySQL高性能-第3版》&…

故障注入测试有哪些多重作用?

在软件开发的世界中&#xff0c;保证系统的鲁棒性和稳定性至关重要。为了应对各种潜在的故障和异常情况&#xff0c;测试团队采用了各种测试方法&#xff0c;其中之一就是故障注入测试。这种测试方法的目标是有目的地向系统引入故障&#xff0c;以评估系统在面对异常情况时的表…

在pom.xml中添加maven依赖,但是类里面import导入的时候报错

问题&#xff1a; Error:(27, 8) java: 类TestKuDo是公共的, 应在名为 TestKuDo.java 的文件中声明 Error:(7, 23) java: 程序包org.apache.kudu不存在 Error:(8, 23) java: 程序包org.apache.kudu不存在 Error:(9, 23) java: 程序包org.apache.kudu不存在 Error:(10, 30) jav…

【VRTK】【VR开发】【Unity】11-甩臂移动

课程配套学习资源下载 https://download.csdn.net/download/weixin_41697242/88485426?spm=1001.2014.3001.5503 【概述】 除了一般的移动能力,VRTK还提供更为沉浸的甩臂移动。 【设定摇杆输入中间件】 在Hierarchy中展开Button Input Actions,其下生成两个新的空子对象…

震撼!这个Python模块竟然能自动修复代码!

说到Python的强大的地方&#xff0c;那真的是太多了&#xff0c;优雅、简洁、丰富且强大的第三方库、开发速度快&#xff0c;社区活跃度高等&#xff0c;所以才使得Python才会如此的受欢迎。 今天给大家介绍一个特别暴力的Python库: FuckIt&#xff0c; 1、FuckIt介绍 FuckI…

接口管理——Swagger

Swagger是一个用于设计、构建和文档化API的工具集。它包括一系列工具&#xff0c;如Swagger Editor&#xff08;用于编辑Swagger规范&#xff09;、Swagger UI&#xff08;用于可视化API文档&#xff09;和Swagger Codegen&#xff08;用于根据API定义生成客户端库、server stu…

文件搜索项目演示

演示功能搜索功能1&#xff1a;根据文件名搜索2&#xff1a;根据文件路径搜索3&#xff1a;根据文件名拼音(全拼、首拼)搜索 选择更新目录功能自动初始化和定时更新功能程序文件项目知识介绍 演示功能 搜索功能 1&#xff1a;根据文件名搜索 2&#xff1a;根据文件路径搜索 3…

Unity中后处理 脚本 和 Shader

文章目录 前言一、我们先创建一个默认的后处理Shader&#xff0c;用于脚本测试二、在脚本中使用Graphics.Blit();1、我们先公开一个材质&#xff0c;用于测试后处理效果2、因为在实际开发中&#xff0c;我们不可能为每一个后处理Shader创建对应的材质球。所以&#xff0c;需要对…

flink-1.17.2的单节点部署

flink 简介 Apache Flink 是一个开源的流处理和批处理框架&#xff0c;用于大数据处理和分析。它旨在以实时和批处理模式高效处理大量数据。Flink 支持事件时间处理、精确一次语义、有状态计算等关键功能。 以下是与Apache Flink相关的一些主要特性和概念&#xff1a; 流处理…

MySQL进阶(MySQL学习笔记)

接上回MySQL基础篇 数据完整性约束 定义完整性约束 实体完整性 主键约束 &#xff08;1&#xff09;作为列的完整性约束 &#xff08;2&#xff09;作为表的完整性约束 2.候选键约束 将id字段和user字段设置为候选键 参照完整性 将classid字段设置为外键 用户定义完整性…

【数据结构第 6 章 ②】- 用 C 语言实现邻接矩阵

目录 一、邻接矩阵表示法 二、AMGraph.h 三、AMGraph.c 四、Test.c 【数据结构第 6 章 ① 】- 图的定义和基本术语-CSDN博客 由于图的结构比较复杂&#xff0c;任意两个顶点之间都可能存在联系&#xff0c;因此无法以数据元素在存储区中的物理位置来表示元素之间的关系&…

内核上项目【通信】

文章目录 目的操作步骤逆向分析实现代码参考文献 目的 在Win7 64位系统上编写驱动利用ExRegisterAttributeInformationCallback注册回调进行通信 操作步骤 1.利用MmGetSystemRoutineAddress获取ExRegisterAttributeInformationCallback中ExpDisSetAttributeInformation、Exp…

detectron2中save_text_instance_predictions⭐

save_text_instance_predictions demo.py中修改关于路径os.path.join()函数用于路径拼接文件路径&#xff0c;可以传入多个路径os.path.basename(path)就是给定一串路径的最终找到的那个文件python官方文档链接 将 Python 对象序列化为 JSON 字符串with open 打开文件&#xff…

基于.NET Core + Quartz.NET+ Vue + IView开箱即用的定时任务UI

前言 定时任务调度应该是平时业务开发中比较常见的需求&#xff0c;比如说微信文章定时发布、定时更新某一个业务状态、定时删除一些冗余数据等等。今天给大家推荐一个基于.NET Core Quartz.NET Vue IView开箱即用的定时任务UI&#xff08;不依赖数据库,只需在界面做简单配…

java--HashMap、LinkedHashMap、TreeMap底层原理

1.HashMap集合的底层原理 ①HashMap跟HashSet的底层原理是一模一样的&#xff0c;都是基于哈希表实现的。 ②实际上&#xff1a;原来学的Set系列集合的底层原理就是基于Map实现的&#xff0c;只是Set集合中的元素只要键数据&#xff0c;不要值数据而已。 2.哈希表 ①JDK8之前…

如何使用nacos进行配置管理以及代码集成

首先需要在maven的pom文件中引入nacos-config依赖 <!--nacos配置管理依赖--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency> 在项目中添加boo…

好用便签有什么软件?好用的便签是什么

在工作中&#xff0c;我经常需要记录一些重要的信息&#xff0c;以便在需要时能够快速查找。但是&#xff0c;我曾经使用过的便签软件总是让我感到不满意&#xff0c;要么功能不够强大&#xff0c;要么使用起来不够方便。我一直在寻找一款好用的便签软件&#xff0c;能够让我事…

使用Kali Linux端口扫描

端口扫描 【实训目的】 掌握端口扫描的基本概念和端口扫描的原理&#xff0c;掌握各种类型端口扫描的方法及其区别。 【场景描述】 在虚拟机环境下配置4个虚拟系统“Win XP1” “Win XP2” “Kali Linux”和“Metasploitable2”&#xff0c;使得4个系统之间能够相互通信。实…