- 1、本文档共52页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第7讲 图的算法
第4章 图的算法 图的概念 图的搜索问题 拓扑排序 强连通分支 最小生成树算法 最短路径算法 欧拉回路与中国邮递员问题 网络流及其应用 1. 图的概念 Graphs Definitions Graph Traversals Depth First Search (DFS) Breadth First Search (BFS) Topological Sort Shortest Paths Problems Minimum Spanning Tree (MST) 哥尼斯堡七桥问题 从任一地出发,是否能在每座桥只通过一次的前提下,游历全城最后又返回到原出发地? 有向图 有向图(directed graph, digraph)定义为二元组 G = (V, E) 这里 V 是顶点(节点)的集合, E 是边的集合(一条边表示为两个顶点组成的有序二元组). Vertices are often also called nodes. 边集 E 中的元素 (v, w) 是有方向的,通常用带箭头的线段表示。 无向图 无向图 (undirected graph)定义为二元组 G = (V, E) 这里 V 是顶点(节点)的集合, E 是边的集合 (一条边表示为两个顶点组成的无序二元组). E is a set of unordered pairs of distinct elements of V. Vertices are often also called nodes. Elements of E are called edges, or undirected edges. Each edge may be considered as a subset of V containing two elements, {v, w} denotes an undirected edge In diagrams this edge is the line v---w. In text we simple write vw, or wv vw is said to be incident upon the vertices v and w 赋权图 A weighted graph is a triple (V, E, W) where (V, E) is a graph (directed or undirected) and W is a function from E into R, the reals for an edge e, W(e) is called the weight of e. 图的表示 邻接矩阵 Let G = (V,E), n = |V|, m = |E|, V = {v1, v2, …, vn) G can be represented by an n ? n matrix 赋权图的邻接矩阵 邻接链表阵列 赋权图的邻接链表阵列 复杂度分析 邻接表阵列表示法所需要的存储空间为: O(max(V,E))= O(V+E) 有关图的术语 Subgraph complete graph Adjacency relation Path, simple path, reachable Connected, Strongly Connected Cycle, simple cycle acyclic undirected forest free tree, undirected tree rooted tree Connected component 子图、阶与路径 A subgraph G =(V,E) of a graph G=(V,E) consists of a subset of V?V, and E ? E, such that each edge in E is a connection between a pair of vertices in V. The number of vertices is denoted by |V|, and the number of edges is denoted by |E|. A sequence of vertices, v1,v2,...,vn forms a path of length n–1 if there exist edges from vi to vi+1 for 1 ≤ i n. 环路与连通性 A cycle is just a nonempty path such that the first and last vertices are iden
文档评论(0)