网站大量收购独家精品文档,联系QQ:2885784924

GraphTraversal讲述.pptx

  1. 1、本文档共122页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
GraphTraversal讲述

Graph Traversal;Contents ;Flavors of Graphs;Graphs;Real Life Examples;Flavor of Graphs;Directed vs. Undirected Graphs;有向图;Weighted vs. Unweighted Graphs;带权图;Simple vs. Non-simple Graphs;Sparse vs. Dense Graphs;稀疏图和稠密图;Cyclic vs. Acyclic Graphs;Implicit vs. Explicit Graphs;Isomorphism Graphs;The Friendship Graph;If I am your friend, does that mean you are my friend?;Am I my own friend?;Am I linked by some chain of friends to the President?;路径和圈;How close is my link to the President?;Is there a path of friends between any two people?;连通性;Who has the most friends?;生成树;完全图和补图;术语示意;二分图;相交图、区间图;Data Structures for graph ;Data Structures for Graphs;Adjacency Matrix Representation;Adjacency Matrix Representation;Adjacency Matrix Representation;相关问题;Adjacency Lists Representation;Adjacency Lists Representation;Adjacency Lists Representation;Adjacency Lists Representation;相关问题;;Tradeoffs Between Adjacency Lists and Adjacency Matrices;Question – Adjacency Matrix or List?;前向星表示;Think About;Graph traversal basic;Traversing a Graph;Marking Vertices;Marking Vertices;Marking Vertices;To Do List;Breadth-First Search;BFS基本算法;BFS(G, s) 1 for each vertex u ∈ V [G] - {s} 2 do color[u] ← WHITE 3 d[u] ← ∞ 4 p[u] ← NIL 5 color[s] ← GRAY 6 d[s] ← 0 7 p[s] ← NIL 8 Q ← ? 9 ENQUEUE(Q, s) 10 while Q ≠ ? 11 do u ← DEQUEUE(Q) 12 for each v ∈ Adj[u] 13 do if color[v] = WHITE 14 then color[v] ← GRAY 15 d[v] ← d[u] + 1 16 p[v] ← u 17 ENQUEUE(Q, v) 18 color[u] ← BLACK ;;void bfs(int s) { queueint c; color[s] = 1; dist[s] = 0; parent[s] = -1; c.push(s); while(!c.empty()){ u = c.front(); c.pop(); /* do sth when vertex discovered */ printf(%d ,u); for(int i=0;igraph[u].size();i++) { v = graph[u][i]; if (color[v]==0) { color[v]=1; parent[v] = u; dist[v] = dist[u] + 1; c.push(v);

文档评论(0)

jiayou10 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8133070117000003

1亿VIP精品文档

相关文档