CS106B Lecture 23 Graph
来源:互联网 发布:循环冗余检查 数据丢失 编辑:程序博客网 时间:2024/04/28 05:33
DS&A in java
P378
Graph representation
1. adjacency list which represents all vertices adjacent to each vertex
using linked list or star representation
2.adjacency matrix
3. incidence matrix
Note: 1 is suitable for find vertices next to v
2 and 3 are good for node insertion and deletion
最短路径算法
Dijkstra
Floyd
Bellman–Ford algorithm
label-correcting algorithms
Floyd–Warshall algorithm
spanning tree
Kruskal's algorithm
最大流算法
Struct arc{
node * start, *end;
};
Struct node{
vector<arc *> outgoing;
};
DFS(Node v) {
Create a Set<Node> of visited nodesCreate a Stack<Node> of nodes to visit;
Add v to the stack;
while (The stack is not empty) {
Pop a node from the stack, let it be u;
if u is in the visited set
continue
for (Node w connected to u)
Push w onto the stack;
}
}
Problems with DFS
1 .Useful when trying to explore everything.
2. Not good at finding specific nodes
BFS(Node v, Set<Node> visited) {
Create a Queue<Node> of nodes to visit;
Add v to the queue;
while (The queue is not empty) {
Dequeue a node from the queue, let it be u;
if (u has been visited) continue;
Add u to the visited set;
for (Node w connected to u)
Enqueue w in the queue;
}
}
Word ladder
Classic Graph Algorithms
graph coloring
- CS106B Lecture 23 Graph
- CS106B Lecture 15 sort
- stanford cs106b recursion demo
- stanford cs106b random.h demo
- cs106b DigitSum recursive implementation demo
- stanford cs106b mutual recursion demo
- graph
- Graph
- Graph
- graph
- Graph
- Graph
- Graph
- graph
- Graph
- Graph
- graph
- Graph
- 十年MFC经历认识的Microsoft技术
- 【XEN学习笔记】学习授权表(Grant Tables)
- 怎样判断ios app 第一次启动
- 黑马小日子--文件上传
- 黑马小日子--Servlet监听
- CS106B Lecture 23 Graph
- Dom4j解析XML应用总结
- 实现应用程序icon及UITabBar右上角带红圈中数字
- 进入开源虚拟机 XEN 的世界
- Ubuntu 12.04 下安装 Eclipse
- 统计输入中关键词出现的次数(二分查找实现)
- 黑马小日子--过滤器
- 个人申请开发者账号及IDP(iOS Developer Program)注册小计
- 在线广告的exploration/exploitation trade-off(勘探和开采问题)