Professional Documents
Culture Documents
Import Import Import As Import As: # - Coding: Utf-8
Import Import Import As Import As: # - Coding: Utf-8
py
localhost:4649/?mode=python 2/3
22/08/2020 MFDS-Assignment2-2019hc04888.py
111
112 def compare_algorithm(matrix, order):
113 """
114 Function to call both algorithm for each order
115 Args:
116 matrix:
117 order:
118 Returns:
119 """
120 results = np.zeros((order, order)) # Zero Matrix to store result.
121 warshall_algorithm(matrix=matrix, order=order)
122 naive_algorithm(matrix=matrix, order=order, results=results)
123
124 def main(order):
125 """
126 Entry Point.
127 Args:
128 order:
129 Returns:
130 """
131
132 # Test/Sample Matrix to verify the Implementation.
133 # First Matrix is taken from Lecture PPT and other from Book to verify
the answers
134 # order = 4
135 # matrix = [[1, 0, 0, 1],
136 # [0, 1, 1, 0],
137 # [0, 0, 0, 1],
138 # [0, 0, 0, 0]]
139 # matrix = [[1, 1, 0, 1],
140 # [0, 1, 1, 0],
141 # [0, 0, 1, 1],
142 # [0, 0, 0, 1]
143 # ]
144
145 matrix_order.append(order)
146 n_dimension_values = np.random.choice([0, 1], size=(order, order))
147 matrix = np.array(n_dimension_values).reshape(order, order)
148 compare_algorithm(matrix=matrix, order=order)
149
150 if __name__ == '__main__':
151 # Numbers between 10 to 100
152 for order_val in range(10, 101):
153 main(order=order_val)
154 PlotTransitiveClosureLogPlot()
155 FindOrderOfAlgorithms()
156
157
localhost:4649/?mode=python 3/3
Log Log Plot
Time Complexity