嗜血魂K

导航

Make notes --Graph Theory

顶点:verticle,also called node

边:edge

边权图(edge-weighted graphs),或者带权图(weighted graphs)点权图(node-weighted graphs)

 

如果一条边的起点和终点都是同一个顶点(form (u,u)),这条边被称为环边(self-loop)

简单(simple)是指在边集 E 中,没有环图,且一条边不重复出现的图。如果图中多次包含了同一条边,或者包含环边,这种图被称作复杂图(multigraph)。

连接(incident)

如果顶点 u 和 v 被一条边相连,那么 u 和 v 就是相连(adjacent)的.

如果边的总数小于可能边的总数 ((N x (N-1))/2),那么这个图是稀疏(sparse),否则就是稠密(dense)

有向图(Directed Graph) && 无向图(Undirected Graph)

有向图中,edge is also called acrs

入度(in-degree) && 出度(out-degree)

路径(Path)

如果在之间存在一条从 u 到 x 路径 p,则称 x 是从 u 经由 p 可达(reachable)

如果所有被经过的顶点在该顶点序列中只出现了一次,那么我们就称它是简单(simple)路径

(cycle)是指起始和结束顶点是相同顶点的路径。简单(simple)是指,除了起始(结束)顶点外,所有被经过的顶点在该环中只出现了一次。

连通性(Connectedness)

如果无向图的每对顶点都有路径相连,它就被称作连通图

非连通图的连通分量(component)是指它的极大连通子图

如果有向图的每对顶点都有路径相连,它就被称作强连通(strongly connected)

一个有向图的强连通分量(strongly connected component)是指非强连通图的极大连通子图。

子图(Subgraphs)

如果 V' 是 V 的子集,而且E' 是 E 的子集,那么图 G' = (V', E') 是 G = (V, E) 的子图

有向无环图(directed acyclic graph)通常被叫做dag。

完全(complete)是指图中的任意顶点对都有边相连的图。

二分(bipartite)是指顶点能被分成2个顶点集 V1 和 V2,并且 V1 和 V2 内部都没有边相连的图。

树的没拉过来了

 

 

FloodFill:真的搞不懂这个。。为什么就从来没听过这个名字= = 包括中文译名。。

USACO 伪代码:

# component(i) denotes the
# component that node i is in
 1 function flood_fill(new_component) 

 2 do
 3   num_visited = 0
 4   for all nodes i
 5     if component(i) = -2
 6       num_visited = num_visited + 1
 7       component(i) = new_component
 8       for all neighbors j of node i
 9         if component(j) = nil
10           component(j) = -2
11 until num_visited = 0 

12 function find_components 

13  num_components = 0
14  for all nodes i
15    component(node i) = nil
16  for all nodes i
17    if component(node i) is nil
18      num_components =
                 num_components + 1
19      component(i) = -2
20      flood_fill(component
                        num_components)

翻译:主函数find_componets,先置所有节点为nil,(NULL?)。

从第一个节点开始。。先看是否已经被扩展过了,没有的话就标记为-2,然后开始搞这个节点。。flood_fill函数,传递的是标记。

先看结束条件,num_visited=0,是说如果这一次扩展没有新节点出来。。就标记完了撒。。所以就结束了 = =

对所有节点。。第一次当然是对主函数标记的节点 == -2

扩展出其相邻节点,没有被扩展过的。

之后每次就是对扩展出来的节点扩展。。

。。。。

Flood Fill就完成了 - =

 

posted on 2012-02-09 13:51  嗜血魂K  阅读(246)  评论(1编辑  收藏  举报