该程序实现图的建立与先深和先广遍历,图采用矩阵存储,在遍历过程中用栈实现,但若改用队列,将会实现得更自然流畅-the program plans to establish the first and the first deep-Traversal, map storage matrix, Traversing in the process of making Stack, but switch queue, there will be more natural and fluid 下载
|
邻结表存储的无向图的建立及遍历输出(包括深度优先与广度优先搜索)- The neighbour ties the table to save non- (first first searches to the chart establishment and the calendar output including depth with breadth) 下载
|
图的遍历中,因为图的任一顶点都可能与其余的顶点相邻接,所以在访问了某个顶点之后,可能沿着某条路径搜索之后又回到该顶点上。为了避免同一顶点被访问多次,在遍历图的过程中必须记下每个已访问过的顶点。深度优先搜索从图的某个顶v点出发,访问此顶点,然后依次从v的未被访问的邻接点出发深度优先遍历图。遍历图的过程实质上是对每个顶点查找其邻接点的过程。其耗费的时间则取决于所采用的存储结构。- 下载
|