Quellcode durchsuchen

logging strings, not object addresses. i hope

tarfeef101 vor 6 Jahren
Ursprung
Commit
3f4044c4e8
1 geänderte Dateien mit 12 neuen und 4 gelöschten Zeilen
  1. 12 4
      a3/router.py

+ 12 - 4
a3/router.py

@@ -64,6 +64,9 @@ class connection:
         this.link = link
         this.cost = cost
         
+    def show(this):
+        print("Link: " + str(this.sender) + " " + str(this.src) + " " + str(this.link) + " " + str(this.cost))
+        
     # infers what this connection's (link's) destination is
     def infer(this, db):
         # search all known paths for one with this link
@@ -85,6 +88,10 @@ class db:
     def __init__(this, routers):
         this.entries = [ [] for i in range(routers) ]
         
+    def show(this):
+        for i in this.entries:
+            show(i)
+        
     def insert(this, connection):
         src = connection.src
         # check each entry in the source's list within entries
@@ -96,7 +103,7 @@ class db:
                 return False
         # not a dupe, insert
         this.entries[src - 1].append(connection)
-        print("Link-State DB: ", this.entries, sep='\n')
+        this.show()
         # update entries and connection to contain
         got_dest = connection.infer(this)
         # insert into graph if we have the endpoints for this edge
@@ -120,7 +127,9 @@ class graph:
         return this.sssp[dest - 1]
         
     def show(this):
-        print("SSSP: ", this.sssp)
+        print("RIB: ")
+        for i in range(0, 5):
+            print("R" + str(rid) + " -> R"+ str(i) + " = " + str(this.sssp[i]))
         
     def insert(this, connection):
         src = connection.src
@@ -168,8 +177,7 @@ class graph:
             # no change, we are disconnected. breka
             if (mindexsofar == curnode):
                 break
-            
-        print("SSSP: this.sssp")
+