neo4j逻辑门模拟,如何? [英] neo4j logic gate simulation, how to?
问题描述
我想在有向图中创建一堆和,或和不门。
然后遍历输入,看看它们的结果是什么。
我假设有一个可以做的遍历,但我没有看到它。
我不知道这样的遍历的名字是什么。
当然宽度首先不会完成这项工作。
我需要得到所有的叶子,然后朝着根。
换句话说
A =(B&(C& Z))
我需要首先解决C @ Z问题。
我需要将这种类型的东西放在图中并遍历。
使用Neo4j 2.0,我将使用Labels作为3种类型的操作。
我假设你的叶子会是布尔值?其实我认为你有很多根,只有一个叶子(结果表达式)
(input1) - >(:和:{:OR {id:2}) - >(输出)
(input2) - >(:AND {id:1})
(input3)------------------>(:OR {id:2})
然后,您可以在决定标签类型时使用CASE,并使用集合谓词(ALL,ANY)进行计算
<请参阅: http://docs.neo4j.org/chunked/milestone /cypher-query-lang.html
谓词: http://docs.neo4j.org/chunked/milestone/query-function.html
标签: http:// docs .neo4j.org /分块/里程碑/查询match.html#比赛获得,所有节点上带有一个标签
I would like to create a bunch of "and" and "or" and "not" gates in a directed graph. And then traverse from the inputs to see what they results are.
I assume there is a ready made traversal that would do that but I don't see it. I don't know what the name of such a traversal would be.
Certainly breadth first will not do the job. I need to get ALL the leaves, and go up toward the root. In other words
A = (B & (C & Z))
I need to resolve C @ Z first.
I need to put this type of thing in a graph and to traverse up.
You would probably create each of the operations as a node which has N incoming and one outgoing connection. You can of course also have more complex operations encapsuled as a node.
With Neo4j 2.0 I would use Labels for the 3 types of operations.
I assume your leaves would then be boolean values? Actually I think you have many roots and just a single leaf (the result expression)
(input1)-->(:AND {id:1})-->(:OR {id:2})-->(output)
(input2)-->(:AND {id:1})
(input3)------------------>(:OR {id:2})
Then you can use CASE when for decisions on the label type and use the collection predicates (ALL, ANY) for the computation
See: http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html
Predicates: http://docs.neo4j.org/chunked/milestone/query-function.html
Labels: http://docs.neo4j.org/chunked/milestone/query-match.html#match-get-all-nodes-with-a-label
这篇关于neo4j逻辑门模拟,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!