Perform the Breadth First Search algorithm from a source node on a topology in respect the node index metric (without display).
[v,pred] = NARVAL_R_BFSWD(g,i)
network graph.
source node.
vector that gathers the chronological order how network nodes are visited.
vector composed by the predecessor of each node in order to reach the source node.
NARVAL_R_BFSWD constructs the BFS tree inside the graph g in respect with the source node i defined as the root (WIKIPEDIA). This graph search algorithm begins at the root node and explores all the neighboring nodes. Then for each of those nodes with the smallest index, unexplored neighbor nodes are explored, and so on. The search is done in breadth. The vector v gathers the chronological order how the network nodes are visited.pred provides the predecessor of each node in order to reach the source node.
1. Enqueue the root node. 2. Dequeue a node and examine it. * If the element sought is found in this node, quit the search and return a result. * Otherwise enqueue any successors (the direct child nodes) that have not yet been discovered. 3. If the queue is empty, every node on the graph has been examined – quit the search and return "not found". 4. Repeat from Step 2. | ![]() | ![]() |
n=150;//network size L=1000;//network square area side dmax=100;//Locality radius [g]=NARVAL_T_LocalityConnex(n,L,dmax);//generation of a topology in respect with the Locality method i=NARVAL_F_Random(length(g.node_x));//selection of the source node [v,pred]=NARVAL_R_BFSWD(g,i);//application of NARVAL_R_BFSWD i v(1:10)//first ten values pred(1:10)//first ten values | ![]() | ![]() |
Dr. Foued Melakessou
Research Associate
Interdisciplinary Centre for Security, Reliability and Trust
Room F106
University of Luxembourg
6, rue Coudenhove Kalergi
L-1359 Luxembourg-Kirchberg
E-mail: foued.melakessou@uni.lu
Tel: (+352) 46 66 44 5346