我是图表的新手并试图了解如何将上下文关系映射到它们中。
我查看了系统地介绍简单演示的示例(1),例如:
# I want to organize the seating arrangement for my party
# Bob does not like John, so I can say
----------- ------------
| Bob | <--- excludes --- | John |
----------- ------------
但是,如果我想说Bob真的喜欢约翰,但是当他和女友玛丽一起陪伴时不喜欢和他在一起(你知道,他们一直在亲吻,你不能再跟他们说话了)。我考虑过两个解决方案:
# solution 1: create an intermediary node.
# now, the problem is that, if I want to know who John excludes,
# I have to look at the node John + every other node he might be the child of.
| John |
----------- ------------- -----------
| Bob | <--- excludes --- | Couple | <
----------- ------------- ------------
| Mary |
------------
# solution 2: target the edges, and make them cumulative
# here if I want to know who John excludes,
# I just have to target the node John and then check for
# additional logic (in this case, check if Mary is present too).
----------- ------------
| Bob | <--- excludes --- | John |
----------- ^ ------------
^ |
| |
excludes <---- requires (some logic here)
|
----------
| Mary |
----------
请注意,我没有找到这样的任何示例,甚至想知道如果直接在图中处理这类问题是正确的解决方案。任何想法?感谢。
(1)例如关于neo4j,http://www.slideshare.net/thobe/django-and-neo4j-domain-modeling-that-kicks-ass/25-The_Neo4j_Graph_data_model
答案 0 :(得分:1)
我想到了两种方法:
答案 1 :(得分:0)
如果你不把自己的关系局限于他们的关系,而是限于所有人的Power Set,你也可以模拟不同编号的群体之间的关系 - 例如再次使用图表。 在所有节点都是定义集合的一部分的意义上,解决方案是干净的。您必须检查一个人所在的所有节点,正如您已经提到的那样。