-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.py
43 lines (32 loc) · 863 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import csv
import os
class Queue:
def __init__(self):
self.list = []
def push(self, item):
self.list.insert(0, item)
def pop(self):
return self.list.pop()
def isEmpty(self):
return len(self.list) == 0
def __str__(self):
string = ''
for x in self.list:
string += str(x) + ' '
return string
def parse(path):
with open(path, 'rb') as csvfile:
graphcsv = csv.reader(csvfile, delimiter=',')
first = True
e = []
for row in graphcsv:
if first:
v = int(row[0].strip())
first = False
else:
e.append(map((lambda x: int(x.strip())), row))
return v, e
def makeAbsolutePath(path):
if os.path.isabs(path):
return path
return os.getcwd() + '/' + path