Python throwing strange NameError: name <function_name> is not defined
<pre><code>import networkx as nx #@UnresolvedImport
from networkx.algorithms import bipartite #@UnresolvedImport
from operator import itemgetter
from random import choice

corpus = open('/home/abehl/Desktop/Corpus/songs.wx', 'r')

ALPHA = 1.5
EPSILON = 0.5

song_nodes = []
word_nodes = []    

edges = zip(song_nodes, word_nodes)

B = nx.Graph(edges)
degX,degY = bipartite.degrees(B, word_nodes)

sortedSongNodesByDegree = sorted(degX.iteritems(), key=itemgetter(1))
print sortedSongNodesByDegree

song_nodes2 = []
word_nodes2 = []
Vc = list(set(word_nodes))

edges2 = zip(song_nodes2, word_nodes2)
C= nx.Graph(edges2)

for songDegreeTuple in sortedSongNodesByDegree:
    for i in range(songDegreeTuple[1]):
        connectedNodes = C.neighbors(songDegreeTuple[0])
        VcDash = [element for element in Vc if element not in connectedNodes]
        calculateBestNode(VcDash)

def calculateBestNode(VcDashsR):
    nodeToProbailityDict = {}
    for node in VcDashsR:
        degreeOfNode = bipartite(C, [node])[1][node]
        probabiltyForNode = (degreeOfNode ** ALPHA) + EPSILON
        nodeToProbailityDict[node] = probabiltyForNode
</code></pre>

<p>In the above python program, python interpreter is throwing the following error even though the function 'calculateBestNode' is defined in the program. Am I missing something here. </p>

<blockquote>
  <p>NameError: name
  'calculateBestNode' is not defined</p>
</blockquote>

<p>Pardon me for posting a large program here.           </p>
