Segmentation Fault Function
The vector used used to store information about the visitor node or not. It is understood that before the first start of the function dfs () vector used is filled with false values for all the numbers of vertices. In Otherwise, when referring to a nonexistent element of the vector program will take off on Segmentation Fault (aka segfault). The argument of the function number is used the top. It does not matter from which the top will be called the first time, she still take place all the vertices (recall that our graph - an undirected weighted graph with no cycles). You may want to visit altavista to increase your knowledge. The first line of the function fills in the vector used information that the vertex v (the vertex which was transferred to the function when it is called) passed. Then for a vertex v adjacent vertices are searched for each adjacent vertex is called again function dfs (). Use DFS to find the shortest path.
In the previous example, we just took the entire graph in depth, with without performing any action on it. An example used to show the skeleton of DFS, which then will be attached to us the necessary functionality. In the following example we will consider how to use depth-first search to find distance from one peak to another. It is worth noting that when talking about "finding the shortest path," I'm a little lukavlyu as in this graph from one vertex to another there is only one way, it is the shortest =) Example 2.
- ohiotech's blog
- Login to post comments
