Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import networkx
- conn = psycopg2.connect(host="localhost",user="eve",password="eve",database="eve")
- cursor = conn.cursor()
- def getSolarSystemName(solarSystemID):
- cursor.execute("select solarSystemName from mapSolarSystems where solarSystemID = %s;",(solarSystemID,))
- row = cursor.fetchone()
- result = row[0]
- return result
- def getSolarSystemID(solarSystemName):
- cursor.execute("select solarSystemID from mapSolarSystems where solarSystemName = %s;",(solarSystemName,))
- row = cursor.fetchone()
- result = row[0]
- return result
- g = networkx.Graph()
- cursor.execute("select fromSolarSystemID, toSolarSystemID from mapSolarSystemJumps")
- for row in cursor:
- g.add_edge(row[0],row[1])
- jitaid = getSolarSystemID("Jita")
- rensid = getSolarSystemID("Rens")
- shortestpath = networkx.shortest_path(g,jitaid,rensid)
- for node in shortestpath:
- print(getSolarSystemName(node))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement