2012-01-14 12 views
0

私のプロジェクトにrepyでlibをインポートする必要がありますが、それはファウルを返します。 Dijkstraアルゴリズムを使用してモジュールを使用して、シアトルの船舶で航行し、船間の最短経路を表示したいと考えています。seattle環境を使用してrepyでlibをインポートする方法

from priodict import priorityDictionary 

def Dijkstra(G,start,end=None): 

D = {} # dictionary of final distances 
P = {} # dictionary of predecessors 
Q = priorityDictionary() # est.dist. of non-final vert. 
Q[start] = 0 

for v in Q: 
    D[v] = Q[v] 
    if v == end: break 

    for w in G[v]: 
     vwLength = D[v] + G[v][w] 
     if w in D: 
      if vwLength < D[w]: 
       raise ValueError, \ 
    "Dijkstra: found better path to already-final vertex" 
     elif w not in Q or vwLength < Q[w]: 
      Q[w] = vwLength 
      P[w] = v 

return (D,P) 

def shortestPath(G,start,end): 

D,P = Dijkstra(G,start,end) 
Path = [] 
while 1: 
    Path.append(end) 
    if end == start: break 
    end = P[end] 
Path.reverse() 
return Path 

それは、このようなエラーをスロー:

Uncaught exception! Following is a full traceback, and a user traceback. 
The user traceback excludes non-user modules. The most recent call is displayed 
last. 

Full debugging traceback: 
    "repy.py", line 428, in <module> 
    "repy.py", line 178, in main 
    "D:\STUDIA\LAN\seattle\seattle_repy\virtual_namespace.py", line 78, in __init 
_ 

User traceback: 

Exception (with type 'exceptions.ValueError'): Code failed safety check! Error: 
("<class 'safety_exceptions.CheckNodeException'> (4, 'From')",) 

は、私はそれが動作するために何をすべきか?

答えて

0

Googleで見つけたものから、cannot use import in Repyです。代わりに

include priodict.repy 

のようなものを使用してください。

関連する問題