- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在努力理解Cypher是如何对应图数据库理论的。我特别想到了“Peter T.Wood 的图形数据库查询语言”(http://users.dcc.uchile.cl/~pbarcelo/wood.pdf)。我想它对应于具有聚合等附加操作的联合常规路径查询,但我无法在任何地方找到有关此的信息。
两个问题:
背景:我开始使用 Neo4j 和 Cypher 来撰写我正在撰写的论文。我这样做是因为这些似乎都已经建立并且得到了很好的支持。但是,我想从我的查询回答抽象到更一般的图形查询形式主义,但我不知道 Cypher 是如何对应于此的。
最佳答案
我在 LinkedIn 上找到了这个问题的答案,可以在这里找到: https://www.linkedin.com/groups/Does-anybody-know-similarities-differences-2623939.S.5939804856381382658
下面的答案是指这个查询:
MATCH (n:Asteroid) WHERE NOT n.name = 'Ceres' RETURN n LIMIT 25
答案如下:
There are two answers to your question regarding negation:
(i) The negation of a property value
This is the case covered in the comment above, which is essentially correct; I will re-use the provided example. Internally, all nodes having the label 'Asteroid' are retrieved using the label index. This is followed by a “selection” operator (from relational algebra), which is used to select only those tuples containing either no 'name' property or where the 'name' property is not 'Ceres'.This is then followed by an operator called “top”, limiting the results returned to 25. As you can see, this does not differ from how SQL is executed on relational databases.
(ii) The negation of a pattern predicate
This is where the full power of graph pattern matching is utilised.
Say we have the following toy query, in which I want to find all events I have not attended:
MATCH (me:Person {name: “me”}), (e:Event) WHERE NOT ( (me) - [:ATTENDED] -> (e) ) RETURN e
Our query execution plan is a tree of operators, each of which has up to 2 children.
At root of the tree, we have an 'Anti Semi Apply' operator (equivalent to an anti-semijoin operator in relational theory). The left-hand child is a Cartesian Product of two sets of tuples: (1) a set of nodes corresponding to (me:Person {name: "me"}) retrieved using the label and property index, and (2) a set of nodes corresponding to (e:Event), retrieved using the label index. We note that the Cartesian Product will consist of all combinations of "me" nodes with every (e:Event) in the database.
The Cartesian Product emits a single row at a time, and this row, R, is piped upwards to the Anti Semi Apply operator. The Anti Semi Apply then feeds R as an argument to its right-hand branch, so that R appears as the ultimate descendant on the right-hand side. R is passed upwards to an Expand operator, which returns all (me)-[:ATTENDED]-(some_e) rows (note that the "me" here matches the one in R). Immediately, each such row, S, has a Selection operation applied to it, in order to match "some_e" to the "e" in R. Thus, any row S is in effect an "Event" ATTEND by "me". S is then piped to Anti Semi Apply. If no row S was found for R, R is returned as a result (as these will be all “Events” not ATTENDED by "me")
Thus, having negation in a query is not treated as a simple filter - it intrinsically affects the entire query plan.
More details on Cypher’s execution plans can be found at http://neo4j.com/docs/snapshot/execution-plans.html.
关于database - Cypher - 如何处理否定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26972456/
这个问题在这里已经有了答案: Tempered Greedy Token - What is different about placing the dot before the negative l
我想做与THIS相反的事情。换句话说,我该怎么做: SELECT * FROM table1 WHERE col1, col2 NOT IN (SELECT col1, col2
嗨,假设我有这个字符串: var text = "Jackie Chan | Jack Frost | Capt.Jack Sparrow" 我想找到除 Jack Frost 之外的所有 /Jack/
我只想在运行低于 iOS8 操作系统的设备上执行代码块。我做不到: if #available(iOS 8.0, *) == false { doFoo() } 我目前使用的解决方案是: if
我使用 htaccess 来解析对 seo 友好的请求。早些时候我的 htaccess 有这些字符串来解析像 /some/request/ 这样的请求 RewriteCond %{REQUEST_UR
我只想在运行低于 iOS8 操作系统的设备上执行代码块。我做不到: if #available(iOS 8.0, *) == false { doFoo() } 我目前使用的解决方案是: if
我的一个考试题目是: ! ( ! ( a != b) && ( b > 7 ) ) 选择: a) (a != b) || (b 7) 最初,我以为是 D。这是不正确的,我知道为什么。我不明白逻辑
我很难在 Prolog 中寻找关于否定的明确答案,所以如果这是一个明显的问题,我深表歉意: 我正在尝试编写一个简单的代码,从逻辑上说“如果 X 喜欢 Y 并且只喜欢 Y,则 X 和 Y 彼此相爱。”我
假设我有以下字符串: 邮寄至 电话:+358123456 http://www.google.fi 邮箱:foo@bar.fi Hello World 电话 大象 一分钱 链接 猫头鹰 如何在 RE2
如何在 RE2 中为“匹配字符串不以 4 或 5 开头”编写正则表达式? 在 PCRE 中,我会使用 ^(?!4)但 RE2 doesn't support that syntax . 最佳答案 您可
假设我有一个谓词 is_foo?/1在 Elixir 我想在一个将谓词作为参数的函数中使用它,但被否定了。 Elixir 有没有办法简单地做到这一点? 最佳答案 &(!is_foo? &1)应该这样做
假设我想制作一个描述所有整数的 RE。根据定义,表达式为: (+|-)?[0-9]+ 但定义也匹配这些数字:+0, -0, 0045 0045 情况可能可以使用回溯表达式来解决,但是我如何才能从关于。
作为 Javascript 的初学者,我有一个看起来有点奇怪的问题。我正在使用我在网上找到的外部库,我在其中找到了以下代码: if('useHoles' in c){ this.config.u
否定 MySQL 查询的最佳方法是什么,也就是说,无论条件如何,强制它不返回任何记录。 我使用了 AND 1=0 ,它似乎有效,但我有兴趣知道是否有这样的标准。 最佳答案 只需添加一个false条件
我有一个问题:我必须获取所有未在指定时间表中安排的司机姓名。我可以使用以下查询获取指定时间表中安排的所有司机姓名,但我无法否定它。请给我指示如何去做。谢谢。 select drivername fro
我正在做功能测试,刚刚发现了 assert_difference,如: assert_difference('Account.count') do post :create, :account =
考虑这个模式:*.py。它匹配所有以 py 扩展名结尾的路径。现在,是否有可能找到一个匹配其他一切的模式? 我认为这样可以做到:*[!.][!p][!y],但显然 fnmatch.fnmatch总是返
我有以下正则表达式模式:[^\u0001-\u00FF]。这样我就可以验证用户输入不包含“€”等无效字符。 var utfRegex: RegExp = new RegExp('[^\u0001-\u
我尝试使用 vector::erase 和 std::remove_if 从 vector 中删除对象。我有一个外部 namespace 来进行选择: template bool Namespace:
是否有可能/可以实现否定 boost 过滤适配器,例如 std::vector v = {1, 2, 3, 4, 5}; for(auto i : v | !filtered(is_even))
我是一名优秀的程序员,十分优秀!