• No se han encontrado resultados

Traversing graph algorithms

In document LARGE-SCALE SURFACE REGISTRATION (página 79-83)

our purposes:

Apath between two vertices is the set of connected nodes that link them. Figure 3.4-a shows the path betweenv1 and v10.

Acycle is a specialpath where the starting vertex coincides with the ending vertex. In Figure 3.4.b a cycle composed by the verticesC = (v1, v4, v6, v5, v1) is depicted. If the path does not contain any repeated vertex then the path is called a simple path. Analogously, a cycle with no repeated vertices (apart from the starting vertex) is called asimple cycle.

A Hamiltonian cycle is a cycle that connects all the vertices of a graph by visiting each vertex only once (see Figure 3.4-c).

Figure 3.4: Examples of paths and cycles: (a) A simple path coloured in red; (b) A cycle in blue; and (c) a Hamiltonian cycle in green.

A tree is a connected, undirected graph without cycles. When a tree contains all the vertices of a graph, it is called a spanning tree. Note that a graph may have several different spanning trees. For example, the red path in Figure 3.5 represents a possible spanning tree of that graph. ConsideringG(V, E) a graph in which the edges are weighted with non-negative costs, a minimum spanning tree is the tree where the sum of the costs of the edges is minimum. Now that the basics on Graph theory are reviewed, the following sections deal with the algorithms of vertex touring throughout graphs focusing on 3D Registration.

3.2 Traversing graph algorithms 63

Figure 3.5: Spanning tree.

the literature are the Breadth first search (BFS) and the Depth first search (DFS). The difference between both algorithms resides in the way of exploring all the possible paths in the graph.

3.2.1 Breadth first search

The Breadth first search strategy prioritizes the parallel exploration of all the possible paths from the current vertex. This algorithm begins by choosing a vertex (the root in case of a tree) which is labeled with the 0. The next step consists in exploring all the neighbors of this node (adjacent vertices), which are labeled with the 1. Then, for each of the nodes of this level the algorithm explores their neighboring nodes labeling them with the corresponding label. The process ends when all the vertices have been visited.

LedV ={Vi} be the set of vertices of a graph G:

1. Start with all the vertices unlabeled.

2. Select an starting vertex and label it with 0.

3. j = 0 (j represents the level of the visited vertices).

4. From each node labeled j, select all the non-labeled vertices adjacent to it and label them as j + 1. If there is no more unlabeled nodes the process ends.

5. j = j + 1 (increment one level). Go to step 4.

Table 3.1: Breadth first search algorithm.

The result of the Breadth first search algorithm is depicted in Figure 3.6, where the

vertices have been visited following the path: P ={v1, v2, v4, v5, v3, v8, v6, v9, v7, v10}

Figure 3.6: Graph traversing using breadth first search algorithm.

3.2.2 Depth first search

The Depth first search algorithm prioritizes the exploration of a single path from the selected node before backtracking. The first step of this algorithm is to select a vertex (the root in case of a tree), which will be considered thecurrent vertex. Then, the idea is to extend the path to an unvisited vertex neighbor of thecurrent vertex, and so on, going as far as possible along the branch, performing a depth search. When no unvisited vertices are found, a backtracking process is carried out and a new alternative path is considered.

The algorithm ends when all the vertices have been visited. Notice that some vertices can be visited more than once, so that only the first visit is considered in the path. This process and the resultant tree is shown in Figure 3.7, where the vertices have been visited following the path: P ={v1, v2, v3, v7, v4, v8, v6, v5, v9, v10}

Figure 3.7: Graph traversing using depth first search algorithm.

3.2 Traversing graph algorithms 65

LedV ={Vi} be the set of nodes of a graphG:

1. Start with all the vertices labeled as unvisited

2. Select a unvisited vertex, label it as visited and consider it the current vertex 3. Select a neighbor (adjacent) vertex of the current vertex, mark it as visited and

consider it the current vertex

4. If the current vertex has not any unvisited vertex then go back along the path to its parent and consider it again as the current node. If there are unvisited vertices adjacent to the current vertex, repeat steps 3 and 4.

5. If there are unvisited nodes in the graph, go to step2

Table 3.2: Depth first search algorithm.

Considerations

BothBreadthf irstsearch andDepthf irstsearch algorithms provide reliable solutions to the problem of traversing a graph. Besides, these algorithms can be used as well for other problems such as the generation of trees and spanning trees. Although both algorithms deal with the same kind of problems, they have several differences that must be taken into account. That is, depending on the problem we are dealing with, one algorithm may perform better than the other. One of the differences between these algorithms resides in the memory requirements. DFS strategy requires less memory than BSF, since only the path of the current explored branch is recorded. In addition, DFS results very efficient dealing with a searching problem with several solutions where each solution is in a similar depth level of the tree/graph. However, if the searching is along a branch that does not contain any solution, DFS can become very inefficient. Although BFS requires more memory, it usually requires less steps to find the solution (shortest path). For instance, should we have a graph containing a very deep branch and several short branches where the solution of our problem resides in one of the shortest branch, then BFS should be more appropriate than DFS. As it is shown in the following chapters, DFS and BFS algorithms are closely related to several 3D multiview registration techniques. Some related problems such as the order in which the partial views should be registered are determined using DFS and BFS. The graph traversing strategy used in each situation depends on several factors such as the way in which we want to register the views, the sort of object to be registered and the trajectory followed by the camera while the partial views were acquired.

In document LARGE-SCALE SURFACE REGISTRATION (página 79-83)