Так что это график, который содержит сетевые устройства
Ранее, были добавлены узлы, и теперь я пытаюсь добавить больше узлов и добавить отношения к графику. Что я делаю не так. В нижней части второго блока кода сообщение об ошибке говорит, что узел не находится на этом графике, но, как вы можете видеть, узел указан как настоящееmatcher = NodeMatcher(db)
nodes = matcher.match()
for node in nodes:
print(node)
node1 = matcher.match(name="mxxx103")
print(node1)
node2 = matcher.match(name='mxxxcvss01')
print(node2)
for rel in db.relationships.match((node1, node2)):
print(rel)
< /code>
и вывод при запуске вышеуказанного кода < /p>
(_9787:Device {model: 'ASR1000', name: 'mxxx103', scanned: 'Yes'})
(_9788:Device {model: 'ASR1000', name: 'lxxx100', scanned: 'Yes'})
(_9789:Device {model: 'ASR1000', name: 'mxxx100', scanned: 'Yes'})
(_9790:Device {model: 'ASR1000', name: 'txxx100', scanned: 'Yes'})
(_9791:Device {model: 'ASR1000', name: 'mxxx101', scanned: 'Yes'})
(_9792:Device {model: 'ASR1000', name: 'mxxx102', scanned: 'Yes'})
(_9793:Device {model: 'ASR1000', name: 'txxx101', scanned: 'Yes'})
(_9794:Device {model: 'ASR1000', name: 'lxxx101', scanned: 'Yes'})
(_9795:Device {model: 'ASR1000', name: 'cxxx100', scanned: 'Yes'})
(_9796:Device {model: 'ASR1000', name: 'cxxx101', scanned: 'Yes'})
(_9797:Device {capabilities: 'R S I', model: 'WS-C4500X', name: 'mxxxcvss01'})
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in
7 node2=matcher.match(name='mxxxcvss01')
8 print(node2)
----> 9 for rel in db.relationships.match((node1,node2)):
10 print (rel)
C:\Utils\WPy3.6 -32-Qt5\python-3.6.7\lib\site-packages\py2neo\matching.py in __iter__(self)
266 """ Iterate through all matching relationships.
267 """
--> 268 query, parameters = self._query_and_parameters()
269 for record in self.graph.run(query, parameters):
270 yield record[0]
C:\Utils\WPy3.6 -32-Qt5\python-3.6.7\lib\site-packages\py2neo\matching.py in _query_and_parameters(self, count)
311 if len(self._nodes) >= 1 and self._nodes[0] is not None:
312 start_node = Node.cast(self._nodes[0])
--> 313 verify_node(start_node)
314 clauses.append("MATCH (a) WHERE id(a) = {x}")
315 parameters["x"] = start_node.identity
C:\Utils\WPy3.6 -32-Qt5\python-3.6.7\lib\site-packages\py2neo\matching.py in verify_node(n)
288 def verify_node(n):
289 if n.graph != self.graph:
--> 290 raise ValueError("Node %r does not belong to this graph" % n)
291 if n.identity is None:
292 raise ValueError("Node %r is not bound to a graph" % n)
ValueError: Node ({model: 'ASR1000', name: 'mxxx103', scanned: 'Yes'}) does not belong to this graph
Подробнее здесь: https://stackoverflow.com/questions/558 ... -the-graph
Я спускаю ум с py2neo: узел на графике, но не на графике ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение