def initDistAndPrev(self, dist, prev): self.animationEngine.addToFrames(6) self.animationEngine.addToFrames( 7, data=ExtraData.addSingleTableDataAndGet( self.distanceId, dist, "Distance", self.displayNames[self.distanceId], "Distance")) self.animationEngine.addToFrames( 8, data=ExtraData.addSingleTableDataAndGet( self.prevId, prev, "Previous", self.displayNames[self.prevId], "Previous"))
def innerLoop(self, u, v, w, distance, graph, sourceNode, previous): data = ExtraData( self.uID, "u = {}, v = {}, distanceBetween({},{}) = {}".format( u, v, u, v, w)) data.addToTable(self.uID, self.displayNames[self.uID], u) data.addToTable(self.vID, self.displayNames[self.vID], v) data.addToTable(self.wID, self.displayNames[self.wID], w) nodes = [{ "id": u.id, "color": CURRENT_NODE_COLOR }, { "id": v.id, "color": NEIGHBOUR_NODE_COLOR }] self.animationEngine.addToFrames(12, data=data, nodes=nodes) self.animationEngine.addToFrames( 13, edges=self.edgeHighlighter.getEdges(distance, previous, u, v, w, sourceNode, graph), data=ExtraData.addSingleTableDataAndGet( self.innerIfD, "{} + {} < {} = {}".format(distance[u], w, distance[v], distance[u] + w < distance[v]))) self.animationEngine.addToFrames( 14, data=ExtraData.addSingleTableDataAndGet( self.innerIfDBool, str(distance[u] + w < distance[v])))
def firstForLoop(self, dist): self.animationEngine.addToFrames(9) self.animationEngine.addToFrames( 10, data=ExtraData.addSingleTableDataAndGet(self.distanceId, dist, "Distance", self.displayNames)) self.animationEngine.addToFrames(11)
def jLoop(self, j): nodes = [{"id": j.id, "color": SELECTED_NODE_COLOR}] self.animationEngine.addToFrames( 14, data=ExtraData.addSingleTableDataAndGet(self.forLoopJ, j, inlineExp="j ="), nodes=nodes)
def iLoop(self, i): nodes = [{"id": i.id, "color": NEIGHBOUR_NODE_COLOR}] self.animationEngine.addToFrames( 13, data=ExtraData.addSingleTableDataAndGet(self.forLoopI, i, inlineExp="i ="), nodes=nodes)
def setToInf(self, htmlTable): self.animationEngine.addToFrames( 5, data=ExtraData.addSingleTableDataAndGet( self.tableMatrixID, htmlTable, tableName=self.tableMatrixLabel, isShownOnScreen=False))
def innerIf(self, u, v, w, distance, previous, graph, source): data = ExtraData( self.errorUID, "u = {}, v = {}, distanceBetween({},{}) = {}".format( u, v, u, v, w)) self.animationEngine.addToFrames(20, data=data) self.animationEngine.addToFrames( 21, edges=self.edgeHighlighter.getEdges(distance, previous, u, v, w, source, graph), data=ExtraData.addSingleTableDataAndGet( self.errCheckID, "{} + {} ({}) < {}".format(distance[u], w, distance[u] + w, distance[v]))) self.animationEngine.addToFrames( 22, data=ExtraData.addSingleTableDataAndGet( self.outIfDBool, (str((distance[u] + w) < distance[v]))))
def assignDistance(self, i, j, k, distance, htmlTable): exp = self.__createExp(i, j, k, distance) self.animationEngine.addToFrames( 17, data=ExtraData.addSingleTableDataAndGet( self.tableMatrixID, htmlTable, tableName=self.tableMatrixLabel, isShownOnScreen=False), overrideExplanation=exp) self.animationEngine.addToFrames(18, overrideExplanation=exp)
def kLoop(self, i, j, k, distance, htmlTable): nodes = [{ "id": k.id, "color": CURRENT_NODE_COLOR }, { "id": j.id, "color": SELECTED_NODE_COLOR }, { "id": i.id, "color": NEIGHBOUR_NODE_COLOR }] data = ExtraData(self.forLoopK, k, inlineExp="k =", isShownOnScreen=True) data.addToTable(self.tableMatrixID, self.tableMatrixLabel, htmlTable) exp = self.__createExp(i, j, k, distance) self.animationEngine.addToFrames(15, data=data, nodes=nodes, overrideExplanation=exp) self.animationEngine.addToFrames(16, overrideExplanation=exp)
def ifStatement(self, u, v, w, distances, previous): data13 = ExtraData(self.equalDistID, "distance[{}] = {} + {}".format(v, distances[u], w)) data13.addToUpdateDataQueue(self.distanceId, distances, isShownOnScreen=False, inlineExp="Distance") data14 = ExtraData(self.equalPrevID, "previous[{}] = {}".format(v, u)) data14.addToUpdateDataQueue(self.prevId, previous, isShownOnScreen=False, inlineExp="Previous") self.animationEngine.addToFrames(15, data=data13) self.animationEngine.addToFrames(16, data=data14)
def ret(self, dist, prev): self.animationEngine.addToFrames(24) self.animationEngine.addToFrames(25) data = ExtraData(self.distanceId, dist, isShownOnScreen=False, inlineExp="Distance") data.addToUpdateDataQueue(self.prevId, prev, isShownOnScreen=False, inlineExp="Previous") data.addToUpdateDataQueue(self.retID, "Dist {}, OI OI OI Prev {}".format( dist, prev), isShownOnScreen=False) self.animationEngine.addToFrames(26, data=data)