<< NARVAL_R_SinkFlood NARVAL NARVAL_R_TDijkstra >>

NARVAL >> NARVAL > NARVAL_R_TBellmanFord

NARVAL_R_TBellmanFord

Perform the routing table of a topology in respect with the Bellman-Ford algorithm.

Calling Sequence

[rt] = NARVAL_R_TBellmanFord(g)

Parameters

g :

network graph.

rt :

routing table.

Description

NARVAL_R_TBellmanFord computes the shortest paths between all couples of distinct network nodes of the graph g composed by n nodes in respect with the Bellman-Ford algorithm (WIKIPEDIA). The paths are stored in the routing table matrix rt. Thus the route between the nodes i and j can be read at the line of index (i-1)*n+j. The first column of rt provides each path length.

Pseudo-Code (Wikipedia)

procedure BellmanFord(list vertices, list edges, vertex source)
   // This implementation takes in a graph, represented as lists of vertices
   // and edges, and modifies the vertices so that their distance and
   // predecessor attributes store the shortest paths.

   // Step 1: Initialize graph
   for each vertex v in vertices:
       if v is source then v.distance := 0
       else v.distance := infinity
       v.predecessor := null
   
   // Step 2: relax edges repeatedly
   for i from 1 to size(vertices)-1:       
       for each edge uv in edges: // uv is the edge from u to v
           u := uv.source
           v := uv.destination             
           if u.distance + uv.weight is inferior to v.distance:
               v.distance := u.distance + uv.weight
               v.predecessor := u

   // Step 3: check for negative-weight cycles
   for each edge uv in edges:
       u := uv.source
       v := uv.destination
       if u.distance + uv.weight is inferior to v.distance:
           error "Graph contains a negative-weight cycle"

Examples

n=80;//network size
l=1000;//network squared area side
d=100;//Locality radius
[g]=NARVAL_T_LocalityConnex(n,l,d);//generation of a topology
ind=1;//window index
f=NARVAL_G_ShowNodesIndex(g,ind);//graph visualization
[rt]=NARVAL_R_TBellmanFord(g);//application of NARVAL_R_TBellmanFord
rt

Dependency

NARVAL_R_BellmanFord, NARVAL_R_PredRoute, NARVAL_F_RVector

Authors

Foued Melakessou

Contact

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

Home Page


<< NARVAL_R_SinkFlood NARVAL NARVAL_R_TDijkstra >>