In [25]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [5]:
straight = pd.read_csv('straightforward.txt', names=['time', 'compOP', 'overhOP', 'Theoretical estimation'])
In [8]:
straight['Total operations'] = straight.compOP + straight.overhOP
In [10]:
straight['Total operations'] = straight['Total operations'].apply(lambda x : int(x))
In [14]:
straight['compOP'] = straight['compOP'].apply(lambda x : int(x))
straight['overhOP'] = straight['overhOP'].apply(lambda x : int(x))
In [16]:
straight.drop('compOp', inplace=True, axis=1)
In [19]:
straight['Number of Vertices'] = range(33,1000, 33)
In [56]:
straight['Scale Factor'] = straight['Theoretical estimation'] / straight['Total operations']
In [22]:
straight.columns
Out[22]:
In [57]:
straight = straight[[u'Number of Vertices',u'time', u'compOP', u'overhOP', u'Total operations', u'Theoretical estimation', 'Scale Factor']]
In [43]:
heap = pd.read_csv('Heap-Based.txt', names=['time', 'compOP', 'overhOP', 'Theoretical estimation'])
In [45]:
heap['compOP'] = heap['compOP'].apply(lambda x : int(x))
heap['overhOP'] = heap['overhOP'].apply(lambda x : int(x))
In [47]:
heap['Total operations'] = heap.compOP + heap.overhOP
In [50]:
heap['Scale Factor'] = heap['Theoretical estimation'] / heap['Total operations']
In [52]:
heap['Number of Vertices'] = range(33,1000, 33)
In [54]:
heap = heap[[ u'Number of Vertices',u'time', u'compOP', u'overhOP',
u'Total operations', u'Theoretical estimation', u'Scale Factor']]
In [55]:
heap
Out[55]:
In [ ]:
In [ ]:
In [ ]:
In [58]:
plt.figure(figsize=(10,5))
plt.style.use('ggplot')
plt.plot(straight['Number of Vertices'], straight.time, 'r.-')
plt.ylabel('Time (sec)')
plt.xlabel('Number of vertices')
plt.title('Dijkstra algorithm straightforward version')
Out[58]:
In [61]:
plt.figure(figsize=(10,5))
plt.style.use('ggplot')
plt.plot(heap['Number of Vertices'], heap.time, 'y.-')
plt.ylabel('Time (sec)')
plt.xlabel('Number of vertices')
plt.title('Dijkstra algorithm Heap-Based version')
Out[61]:
In [65]:
plt.figure(figsize=(10,5))
plt.style.use('ggplot')
plt.plot(heap['Number of Vertices'], heap.time, 'y.-')
plt.plot(straight['Number of Vertices'], straight.time, 'r.-')
plt.plot((straight['Number of Vertices'] + heap['Number of Vertices'])/2,( straight.time + heap.time)/2, 'b.-')
plt.legend(['Heap-Based','Straightforward', 'Mean'])
plt.ylabel('Time (sec)')
plt.xlabel('Number of vertices')
plt.title('Dijkstra algorithm both version and their mean')
Out[65]:
In [75]:
plt.figure(figsize=(10,5))
# plt.plot(heap['Number of Vertices'], heap['Total operations'], 'y.-')
plt.plot(straight['Number of Vertices'], straight['Total operations'], 'r.-')
# plt.plot((straight['Number of Vertices'] + heap['Number of Vertices'])/2,( straight['Total operations'] + heap['Total operations'])/2, 'b.-')
plt.ylabel('Number of operations')
plt.xlabel('Number of vertices')
plt.title('Straightforward')
Out[75]:
In [66]:
heap
Out[66]:
In [ ]: