|
| 1 | +import csv |
| 2 | +import matplotlib |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +from mpl_toolkits.mplot3d import Axes3D |
| 6 | +import matplotlib.pyplot as plt |
| 7 | + |
| 8 | +csv_read = csv.reader(open('log.txt'), delimiter=',') |
| 9 | + |
| 10 | +n = {1000:[], 2000:[], 3000:[], 4000:[], 5000:[]} |
| 11 | +avgd = {1000:[], 2000:[], 3000:[], 4000:[], 5000:[]} |
| 12 | +two3 = {1000:[], 2000:[], 3000:[], 4000:[], 5000:[]} |
| 13 | +for row in csv_read: |
| 14 | + #import ipdb ; ipdb.set_trace() |
| 15 | + for i, col in enumerate(row): |
| 16 | + |
| 17 | + # 0 - <> |
| 18 | + # 1 - M |
| 19 | + # 2 - N |
| 20 | + # 3 - size |
| 21 | + # 4 - degree min |
| 22 | + # 5 - degree max |
| 23 | + # 6 - shortestpath |
| 24 | + # 7 - 2/3 |
| 25 | + sz = int(row[3]) |
| 26 | + n_rw = int(row[2]) |
| 27 | + avgd_rw = np.mean([int(row[4]), int(row[5])]) |
| 28 | + two3_rw = float(row[7]) |
| 29 | + |
| 30 | + n[sz].append(n_rw) |
| 31 | + avgd[sz].append(avgd_rw) |
| 32 | + two3[sz].append(two3_rw) |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +fig = plt.figure() |
| 37 | +ax = fig.add_subplot(111, projection='3d') |
| 38 | + |
| 39 | +for i, j in enumerate(n[1000]): |
| 40 | + |
| 41 | + print(n[1000][i], avgd[1000][i], two3[1000][i]) |
| 42 | + |
| 43 | +ax.scatter(n[1000], avgd[1000], two3[1000], c='r', marker='x', label='1000') |
| 44 | +ax.scatter(n[2000], avgd[2000], two3[2000], c='g', marker='+', label='2000') |
| 45 | +ax.scatter(n[3000], avgd[3000], two3[3000], c='b', marker='1', label='3000') |
| 46 | +ax.scatter(n[4000], avgd[4000], two3[4000], c='purple', marker='2', label='4000') |
| 47 | +ax.scatter(n[5000], avgd[5000], two3[5000], c='c', marker='3', label='5000') |
| 48 | + |
| 49 | +#ax.set_xscale('log') |
| 50 | +#ax.set_xticklabels([1,2,3,10,100]) |
| 51 | +#ax.set_xticks([1,2,3,10,100]) |
| 52 | + |
| 53 | +ax.set_xlabel('N') |
| 54 | +ax.set_ylabel('Average degree') |
| 55 | +ax.set_zlabel('Time to reach 2/3rds of nodes') |
| 56 | + |
| 57 | +ax.legend() |
| 58 | + |
| 59 | +plt.show() |
0 commit comments