Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class criticalPath:
- def __init__(self):
- '''
- Initialize all the variables we're going to use to calculate the critical path
- '''
- self.id = None
- self.pred = tuple()
- self.dur = None
- self.est = None
- self.lst = None
- #list to store all the objects
- self.all_objects = list()
- def set_properties(self, name, predecessor, duration):
- self.id = name
- self.pred = tuple(predecessor)
- self.dur = duration
- def main():
- #starting_nodes = list()
- object_list = list()
- A = criticalPath()
- A.set_properties('A', '0', 3)
- B = criticalPath()
- B.set_properties('B', '0', 6)
- C = criticalPath()
- C.set_properties('C', 'A', 12)
- D = criticalPath()
- D.set_properties('D', 'B', 4)
- tmp_list = list()
- tmp_list.append(A)
- tmp_list.append(B)
- object_list.append(tmp_list)
- tmp_list = list()
- tmp_list.append(C)
- tmp_list.append(D)
- object_list.append(tmp_list)
- '''for i in object_list:
- if '0' in i.pred:
- _list = list()
- _list.append(i)
- starting_nodes.append(_list)
- print(starting_nodes)'''
- print(max(object_list, key=sum(object_list.dur)))
- if __name__ == '__main__': main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement