How to get say
Buenos Aires - New York - Liverpool in terms of number of days?
and shortest path, say between Buenos Aires - Liverpool?
from py2neo import Graph, Node, Relationship, authenticate
import os
url = os.environ.get('GRAPHENEDB_URL', 'http://localhost:7474')
username = os.environ.get('NEO4J_USERNAME')
password = os.environ.get('NEO4J_PASSWORD')
if username and password:
authenticate(url.strip('http://'), username, password)
graph = Graph(url + '/db/data/')
buenos_aires = Node("Port", name="Buenos Aires")
new_york = Node("Port", name="New York")
liverpool = Node("Port", name="Liverpool")
casablanca = Node("Port", name="Casablanca")
cape_town = Node("Port", name="Cape Town")
graph.create(buenos_aires, new_york, liverpool, casablanca, cape_town)
rel1 = Relationship(buenos_aires, "TRIP_TO", new_york, days=6)
rel2 = Relationship(buenos_aires, "TRIP_TO", casablanca, days=5)
rel3 = Relationship(buenos_aires, "TRIP_TO", cape_town, days=4)
rel4 = Relationship(new_york, "TRIP_TO", liverpool, days=4)
rel5 = Relationship(liverpool, "TRIP_TO", casablanca, days=3)
rel6 = Relationship(liverpool, "TRIP_TO", cape_town, days=6)
rel7 = Relationship(casablanca, "TRIP_TO", liverpool, days=3)
rel8 = Relationship(casablanca, "TRIP_TO", cape_town, days=6)
rel9 = Relationship(cape_town, "TRIP_TO", new_york, days=8)
watch1_rels = graph.create(rel1, rel2, rel3, rel4, rel5, rel6, rel7, rel8, rel9)
watch2_mygraphs = graph.cypher.execute("MATCH (n:Port) RETURN n LIMIT 5")
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.