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']


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if __name__ == '__main__':

In [22]:
straight.columns


Out[22]:
Index([u'time', u'compOP', u'overhOP', u'Theoretical estimation',
       u'Total operations', u'Number of Vertices'],
      dtype='object')

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]:
Number of Vertices time compOP overhOP Total operations Theoretical estimation Scale Factor
0 33 0.002380 95 241 336 212.907207 0.633652
1 66 0.016072 315 690 1005 532.337035 0.529689
2 99 0.044157 583 1208 1791 887.493930 0.495530
3 132 0.080235 775 1605 2380 1265.558957 0.531747
4 165 0.149310 1143 2325 3468 1684.962006 0.485860
5 198 0.216817 1405 2826 4231 2081.582269 0.491984
6 231 0.298069 1644 3301 4945 2501.516482 0.505868
7 264 0.401920 1877 3769 5646 2930.953021 0.519120
8 297 0.509563 2106 4235 6341 3368.692797 0.531256
9 330 0.642780 2378 4761 7139 3827.401152 0.536126
10 363 0.778796 2614 5234 7848 4279.336458 0.545277
11 396 0.940126 2869 5725 8594 4737.280055 0.551231
12 429 1.149434 3125 6226 9351 5200.730036 0.556168
13 462 1.399515 3379 6722 10101 5669.261959 0.561257
14 495 1.577617 3614 7189 10803 6113.702046 0.565926
15 528 1.954037 3836 7639 11475 6591.096876 0.574388
16 561 2.358554 4119 8191 12310 7101.946856 0.576925
17 594 2.599668 4397 8716 13113 7587.612631 0.578633
18 627 2.604014 4651 9209 13860 8076.946962 0.582752
19 660 2.756830 4884 9666 14550 8539.793690 0.586927
20 693 3.407053 5144 10159 15303 9020.634405 0.589468
21 726 3.872325 5426 10700 16126 9549.948900 0.592208
22 759 4.682698 5659 11167 16826 10036.855966 0.596509
23 792 4.602459 5939 11701 17640 10572.505245 0.599348
24 825 4.813377 6168 12167 18335 11080.382588 0.604330
25 858 5.425039 6428 12664 19092 11575.392593 0.606295
26 891 5.930193 6673 13154 19827 12103.957770 0.610479
27 924 7.485437 6904 13623 20527 12619.459908 0.614774
28 957 7.478330 7158 14119 21277 13137.319691 0.617442
29 990 7.668574 7425 14630 22055 13657.455787 0.619245

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]:
<matplotlib.text.Text at 0x7f05031e5550>

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]:
<matplotlib.text.Text at 0x7f05030f45d0>

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]:
<matplotlib.text.Text at 0x7f0502d26390>

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]:
<matplotlib.text.Text at 0x7f05002cec50>

In [66]:
heap


Out[66]:
Number of Vertices time compOP overhOP Total operations Theoretical estimation Scale Factor
0 33 0.002380 95 241 336 212.907207 0.633652
1 66 0.016072 315 690 1005 532.337035 0.529689
2 99 0.044157 583 1208 1791 887.493930 0.495530
3 132 0.080235 775 1605 2380 1265.558957 0.531747
4 165 0.149310 1143 2325 3468 1684.962006 0.485860
5 198 0.216817 1405 2826 4231 2081.582269 0.491984
6 231 0.298069 1644 3301 4945 2501.516482 0.505868
7 264 0.401920 1877 3769 5646 2930.953021 0.519120
8 297 0.509563 2106 4235 6341 3368.692797 0.531256
9 330 0.642780 2378 4761 7139 3827.401152 0.536126
10 363 0.778796 2614 5234 7848 4279.336458 0.545277
11 396 0.940126 2869 5725 8594 4737.280055 0.551231
12 429 1.149434 3125 6226 9351 5200.730036 0.556168
13 462 1.399515 3379 6722 10101 5669.261959 0.561257
14 495 1.577617 3614 7189 10803 6113.702046 0.565926
15 528 1.954037 3836 7639 11475 6591.096876 0.574388
16 561 2.358554 4119 8191 12310 7101.946856 0.576925
17 594 2.599668 4397 8716 13113 7587.612631 0.578633
18 627 2.604014 4651 9209 13860 8076.946962 0.582752
19 660 2.756830 4884 9666 14550 8539.793690 0.586927
20 693 3.407053 5144 10159 15303 9020.634405 0.589468
21 726 3.872325 5426 10700 16126 9549.948900 0.592208
22 759 4.682698 5659 11167 16826 10036.855966 0.596509
23 792 4.602459 5939 11701 17640 10572.505245 0.599348
24 825 4.813377 6168 12167 18335 11080.382588 0.604330
25 858 5.425039 6428 12664 19092 11575.392593 0.606295
26 891 5.930193 6673 13154 19827 12103.957770 0.610479
27 924 7.485437 6904 13623 20527 12619.459908 0.614774
28 957 7.478330 7158 14119 21277 13137.319691 0.617442
29 990 7.668574 7425 14630 22055 13657.455787 0.619245

In [ ]: