|
@@ -127,12 +127,14 @@ class graph:
|
|
|
|
|
|
def lookup(this, dest):
|
|
|
return this.sssp[dest - 1]
|
|
|
-
|
|
|
+
|
|
|
+ # logs RIB to log file
|
|
|
def show(this):
|
|
|
log.write("RIB: " + '\n')
|
|
|
for i in range(0, 5):
|
|
|
log.write("R" + str(rid) + " -> R"+ str(i + 1) + " = " + str(this.sssp[i][0]) + " using node " + str(this.sssp[i][1] + 1) + '\n')
|
|
|
-
|
|
|
+
|
|
|
+ # insert the weight of the connection to the graph for src to dest and vice versa
|
|
|
def insert(this, connection):
|
|
|
src = connection.src
|
|
|
dest = connection.dest
|
|
@@ -161,6 +163,7 @@ class graph:
|
|
|
# visited already
|
|
|
if (unvisited[i] == 0):
|
|
|
continue
|
|
|
+ # only update if going through curnode is faster
|
|
|
result = min((this.sssp[curnode][0] + this.alist[curnode][i]), this.sssp[i][0])
|
|
|
if (result != this.sssp[i][0]):
|
|
|
this.sssp[i] = (result, this.sssp[curnode][1])
|