我在链中有节点,如下所示:
func saveNoteButtonTapped(sender: UIButton) {
guard let selectedCellRow = rowOfLongPressedItem else {
return // rowOfLongPressedItem was nil
}
let realm = try! Realm()
let itemsList = realm2.objects(ItemsList)
var selectedItem = ItemsList[selectedCellRow]
try! realm.write {
selectedItem.counts += 1
let noteTimePair = noteAndTimeEntryObj()
noteTimePair.timeStampOfNote = NSDate()
noteTimePair.note = noteTextField.text
noteTimePair.itemsList = selectedItem
realm.add(noteTimePair)
}
notePopup.hidden = true
notePopup.endEditing(true)
noteTextField.text = ""
}
是否有快速计算(a)<-[:rel]-(b)<-[:rel]-(c) ... (x)
和(a)
,之间的节点(或关系)数量,即使它们之间有数千个节点?到目前为止(x)
已经慢了#34;
注意:我不需要知道其间的节点,我只是想找到距离。
答案 0 :(得分:2)
使用shortestPath方法:
MATCH (martin:Person { name:"Martin Sheen" }),(oliver:Person { name:"Oliver Stone" }),
p = shortestPath((martin)-[*..15]-(oliver))
RETURN length(p)
https://neo4j.com/docs/developer-manual/current/cypher/#query-shortest-path