The proposed approach is performed by a set of algorithms which are implemented in a program. The program loads the input file and constructs a coding and routing scheme for the network corresponding to the input file. The program also provides coding node number and link number as well as other statistics. The work flow of the program is shown in Figure 19..
The python code for drawing a single max flow is listed below. One directed Dot graph is initialized with pydot module in line 2. One edge is created by specifying two nodes’ name in line 8. From line 9 to 14, the properties of the edge are specified by the “set” methods. Finally, the edge is added to the graph in line 15. Similar, the nodes are added in line 17-23. The jpeg file is created by calling dot program in the end.
def draw_flows(net, flow, flow_index, n):
# initialize graph
In the implementation of the topological sort, there is one new array D introduced to maintain the in degree for each node. Initially, D[i] is the total number of incoming edges of node i. During the sort progress, when edge > is removed from the graph, the in degree for node j i.e. D[j] is to deduct by one. To check if one node i has no incoming edge, check if D[i] equals to 0, e.g. line 21.
def topologicial_sorting(graph):
global s, n
# Empty list that will contain the sorted elements