Esempio n. 1
0
 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])))
Esempio n. 2
0
 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"))
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 def setToInf(self, htmlTable):
     self.animationEngine.addToFrames(
         5,
         data=ExtraData.addSingleTableDataAndGet(
             self.tableMatrixID,
             htmlTable,
             tableName=self.tableMatrixLabel,
             isShownOnScreen=False))
Esempio n. 7
0
    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]))))
Esempio n. 8
0
 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)