In order to test the network coding solution, random topologies are generated. The number of node (n), edges (m), number of sink nodes (l) and maximum capacity(c) of each edge are specified. There are m edges, each edge is started and ended at two different random selected nodes, with a random integer capacity no more than c.
As an acyclic graph is required, the Floyd-Warshall algorithm is applied to detect and break the cyclic. Firstly, the standard Floyd-Warshall algorithm is applied to work out the shortest path among all the node pairs. Then it is checked to see if there is a path starting and ending at the same node, if there is, a cycle is detected.
procedure floyd_cycle_detection(graph, n)
begin
for k = 1 to n
for i = 1 to n
for j = 1 to n
if graph[i][k] and graph[k][j] then
graph[i][j] = True
for i = 1 to n
if graph[i][i] then return “This is a cyclic graph”
return “This is a acyclic graph”
end
In order to break a cycle, the path reconstruction information is recorded when finding the shortest path. If a cycle is detected, then one edge on the path of the cycle is removed to break that cycle.
procedure floyd_break_cycle (graph, n)
begin
for k = 1 to n
for i = 1 to n
for j = 1 to n
if graph[i][k] and graph[k][j] then
graph[i][j] = True
pred[i][j] = k
for i = 1 to n
if graph[i][i] then
remove the edge
end
As there might be more than one cycle covering the same node, and this cycle break method can break only one cycle at a time, therefore it has to iterate until there is no more cycles detected.
In addition, in order to keep the edge distribution balanced, when breaking the cycle, the order of node visitation can be shuffled.
One randomly generated network example is shown in Figure 26., the source node is 0 and the sink nodes are 8 to 19. Each of the sink nodes are filled with different colours. The capacity of each edge is marked at the side of it.
Share with your friends: |