Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4043552
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:08:29+00:00 2026-05-20T13:08:29+00:00

I am having some trouble in determining the distance of each node from the

  • 0

I am having some trouble in determining the distance of each node from the start node, or rather getting any information back at all.
I get no output from my function, attached in the following link.

#Values to assign to each node
class Node:
     distFromSource = infinity
     previous = invalid_node
     visited = False

#for each node assign default values    
def populateNodeTable(network): 
    nodeTable = []
    index = 0
    f = open('network.txt', 'r')
    for line in f: 
      node = map(int, line.split(',')) 
      nodeTable.append(Node())

      print "The previous node is " ,nodeTable[index].previous 
      print "The distance from source is " ,nodeTable[index].distFromSource 
      index +=1
    nodeTable[startNode].distFromSource = 0 

    return nodeTable

#calculate the distance of each node from the start node
def tentativeDistance(currentNode, nodeTable):
    nearestNeighbour = []
    for currentNode in nearestNeighbour:
      currentDistance == currentNode.distFromSource + [currentNode][nearestNeighbour] #gets current distance from source
      print "The current distance"
      if currentDistance != 0 & currentNode.distFromSource < Node[currentNode].distFromSource:
         nodeTable[currentNode].previous = currentNode
         nodeTable[currentNode].length = currentDistance
         nodeTable[currentNode].visited = True
         nodeTable[currentNode] +=1
         nearestNeighbour.append(currentNode)
         for currentNode in nearestNeighbour:
           print nearestNeighbour

    return nearestNeighbour

My logic is, at least in my mind, correct; however, I don’t get as much as an error message when the code is run.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:08:29+00:00Added an answer on May 20, 2026 at 1:08 pm

    You’re setting nearestNeighbour to be an empty list, and then you’re looping over it with for currentNode in nearestNeighbour — which does nothing, because the list is empty — and then you’re returning from the function.

    (I assume tentativeDistance is the function you’re calling and seeing nothing from.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having some trouble getting a JSON feed to load from my site. I'm starting
I'm having some trouble getting results from a c# OleDbCommand on an MS Access
Im having some trouble determining how to write files using a Java Web Start
I'm having some trouble determining the correct context for a node set. I have
I am having some trouble determining if two line segments are collinear because of
Having some trouble getting a screenscraper webservice up and running on a weblogic 10.3.3
I'm having trouble determining the best way to read some input in for a
Having some trouble w/ IE7. IE8, Chrome, Firefox all work fine, but IE7 won't
Having some trouble passing values from one class to another. I basically have a
I'm having some trouble getting debug mode to work on my android phone. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.