我试图运行neomodel以下的Cypher查询:的Neo4j,py2neo,Neomodel - Cypher支架最短路径给错误 - 类型错误: 'NotImplementedType' 对象不是可调用
MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }),
p = shortestPath((b1)-[*..15]-(b2))
RETURN p
它通过对Neo4j的伟大工程服务器控制台。它返回两个连接关系的3个节点。然而,当我尝试在Python以下几点:
# Py2Neo version of cypher query in python
from py2neo import neo4j
graph_db = neo4j.GraphDatabaseService()
shortest_path_text = "MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }), p = shortestPath((b1)-[*..15]-(b2)) RETURN p"
results = neo4j.CypherQuery(graph_db, shortest_path_text).execute()
或
# neomodel version of cypher query in python
from neomodel import db
shortest_path_text = "MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }), p = shortestPath((b1)-[*..15]-(b2)) RETURN p"
results, meta = db.cypher_query(shortest_path_text)
均可以得到以下错误:
/Library/Python/2.7/site-packages/neomodel-1.0.1-py2.7.egg/neomodel/util.py in _hydrated(data)
73 elif obj_type == 'relationship':
74 return Rel(data)
---> 75 raise NotImplemented("Don't know how to inflate: " + repr(data))
76 elif neo4j.is_collection(data):
77 return type(data)([_hydrated(datum) for datum in data])
TypeError: 'NotImplementedType' object is not callable
这是有道理的考虑neomodel基于py2neo。
主要问题是如何让shortestPath查询通过其中任何一个工作? python中有更好的方法吗?或者是密码的最佳方式呢?
编辑:
我也试过以下从here给出了同样的错误。
graph_db = neo4j.GraphDatabaseService()
query_string = "START beginning=node(1), end=node(4) \
MATCH p = shortestPath(beginning-[*..500]-end) \
RETURN p"
result = neo4j.CypherQuery(graph_db, query_string).execute()
for r in result:
print type(r) # r is a py2neo.util.Record object
print type(r.p) # p is a py2neo.neo4j.Path object
谢谢你Nigel。你能发布你的代码示例吗?我很好奇如何在python中运行原始py2neo密码查询正如我以为这是我在上面做的.. – raschwab 2014-10-03 02:54:18