下载此文档

算法分析与设计2005春.课件.第07讲6.pdf


文档分类:高等教育 | 页数:约11页 举报非法文档有奖
1/11
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/11 下载此文档
文档列表 文档介绍
内容提要
第七讲图的基本算法 Representation of graphics
Breadth-first search
清华大学 Depth-first search
宋斌恒 Topological sort
Strongly ponents
清华大学宋斌恒 1 清华大学宋斌恒 2
图的应用背景 Representation of graphs
可以利用图描述的经典问题有 Definition of a graph:
G = (V, E) where V is a set of vertices, E is
Work Flow another set call Edges is a sub set of {(u,v): u
城市与连接城市的道路 and v is element of V}
区域与隔离区域间的分界线 Concepts of graphs:
人与人之间的认识关系 Dense graph: if |E| is close to |V|2.
任何二元关系都可以用图来表示
Sparse graph: If it is not dense
基本算法的应用
许多与图有关的算法需要做一种搜索
清华大学宋斌恒 3 清华大学宋斌恒 4
2 4 /
1 2 2 5 / 2 3
0 1 0 0 1 1 0 1 0 1 0 0
1 5 3 4 / 5 /
1 0 1 1 1 0 0 0 0 1 0
6 5
3 2 4 / 0 1 0 1 0 / 0 0 0 0 1 1
2 5 3 / 0 1 1 0 1 2 / 0 1 0 0 0 0
1 1 0 1 0
5 4 4 1 2 / 5 4 6 4 / 0 0 0 1 0 0
/ 0 0 0 0 0 0
Figure Two representations of an undirected graph.
(a) An undirected graph G having five vertices and seven edges.
(b) An adjacency-list representation of G.
(c) The adjacency-matrix representation of G.
清华大学宋斌恒 5 清华大学宋斌恒 6
1
Data structure of Adjacency-list
Adjacency-list representation
representation
Let G be a graph, for any u ∈ V, we A set of vertex objects
denote Adj[u] = { v: (u,v) ∈ E}, call the list Vertex object contains one vertex u, and a
of all adjacency vertices of u. set of vertices Adj[u], which contains all its
In general element in Adj[u] is unordered adjacency vertices of u.
In an undirected graph ? Using what data structure to represent a
Sum(Adj[u], for all u ∈ V) = 2 |E| set for the vertex objects
But in a directed graph ? Using what data structure to represent a
Sum(Adj[u], for all u ∈ V) = 1 |E| set for Adj[u]
清华大学宋斌恒 7 清华大学宋斌恒 8
Adjacency-list representation for
Weighted Graph
Weighted Graphics
We can assign value to the edges of a We reconstruct the set Adj[u] as
graph, then we call such a graph is a Adj[u]={(v,r): v ∈ V, r ∈ R} where R is the
weighted graph. space of real number or generally any object
Classi

算法分析与设计2005春.课件.第07讲6 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数11
  • 收藏数0 收藏
  • 顶次数0
  • 上传人中国课件站
  • 文件大小0 KB
  • 时间2011-10-11