Jason Scheirer avatar Jason Scheirer committed fe3ea26

Work-in-progress

Comments (0)

Files changed (1)

 
 type RouteNode struct {
 	minscore, cost uint64
-	direction uint8
+	direction      uint8
 }
 
 func CreateNode(node_score uint64) RouteNode {
 			nodeValues := strings.Split(lineString, ",")
 			for index := 0; index < len(nodeValues); index++ {
 				val, err := strconv.ParseUint(nodeValues[index], 10, 64)
-				if (err != nil) {
+				if err != nil {
 					fmt.Printf("Error reading data\n")
 					return
 				}
 			matrix = append(matrix, row)
 		}
 	}
+
+	maxrow := len(matrix)
+	for rowindex := 0; rowindex < maxrow; rowindex++ {
+		maxcol := len(matrix[rowindex])
+		for colindex := 0; colindex < maxcol; colindex += 1 {
+			newmax := matrix[rowindex][colindex].minscore + matrix[rowindex][colindex].cost
+			if (colindex < maxcol - 1) {
+				if (matrix[rowindex][colindex + 1].direction == UNSET || matrix[rowindex][colindex + 1].minscore > newmax) {
+					matrix[rowindex][colindex + 1].minscore = newmax
+					matrix[rowindex][colindex + 1].direction = LEFT
+				}
+			}
+			if (rowindex < maxrow - 1) {
+				if (matrix[rowindex + 1][colindex].direction == UNSET || matrix[rowindex + 1][colindex].minscore > newmax) {
+					matrix[rowindex + 1][colindex].minscore = newmax
+					matrix[rowindex + 1][colindex].direction = UP
+				}
+			}
+		}
+	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.