2012-01-14 3 views
0

lib를 내 프로젝트에 repy로 가져와야하지만 파울을 반환합니다. 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 

과 같은 것을 사용하십시오.