User Profile

Collapse

Profile Sidebar

Collapse
Greg Jackson
Greg Jackson
Last Activity: Jul 19 '11, 06:24 PM
Joined: Feb 22 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Calculating Distance From Start Node - Dijkstra's Algorithm

    Hello,

    I am having some trouble in working out the distance of each node from the starting node in my Dijkstra Algorithm code. Here is my code with the section i'm stuck on in bold:

    Code:
    infinity = 1000000
    invalid_node = -1
    startNode = 0
    
    class Node:
         distFromSource = infinity
         previous = invalid_node
         visited = False
        
    def populateNodeTable():
    ...
    See more | Go to post

  • How Can I Set First Number on Each Text File Line to be Initial Node in Dijkstra?

    Hello,

    I am attempting to recreate Dijkstra's algorithm in Python but everything is going wrong.
    Here is my code:

    Code:
    def twoDArray():
        network = []
        sourceNode[]       
        f = open('twoDArray.txt', 'r')
        #network = []  
        for line in f:
                    sourceNode.append(line.split(',') [0])
    	line = line = line.rstrip('\n')
    	row = line.split(',')
    ...
    See more | Go to post
No activity results to display
Show More
Working...