摘要: #__author__=lx#__date__=2011-10-03#__brief__=DFStime = 0d = []f = []color = []p = []def DFS_VISIT( G, i ): color[ i ] = 'gray' global time time += 1 d[i] = time print i+1 for v in G[i]: if color[v-1] == 'white': p[v-1] =... 阅读全文
posted @ 2011-10-03 20:21 lxgeek 阅读(240) 评论(0) 推荐(0)
摘要: #__author__=lx#__date__=2011-10-03#__brief__=BFSfrom collections import dequedef BFS( G, s ): d = [] color = [] p = [] L = deque() for i in range( len( G ) ): if i != s: color.append( 'white' ) d.append( ... 阅读全文
posted @ 2011-10-03 19:52 lxgeek 阅读(358) 评论(0) 推荐(0)