简体   繁体   English

节点之间的Neo4j方向

[英]Neo4j direction between nodes

Suppose I have A class which HAS A class B. Then in the graph the direction is outgoing from A or incoming to A? 假设我有一个班级,而有一个班级B。那么在图中,方向是从A传出还是传入A? My main question is how to figure out direction between nodes based on class relationships in a OOD. 我的主要问题是如何根据OOD中的类关系确定节点之间的方向。 Thanks in advance. 提前致谢。

You can easily traverse both ways in Neo4j. 您可以在Neo4j中轻松地双向浏览。 My usual default here is outgoing, that said... it depends on your model. 我通常的默认值是传出的,也就是说...取决于您的型号。

As an exercise, think about people and houses. 作为练习,考虑一下人和房屋。 Does a person have a house or a house have occupants Try thinking about relationship names here. 一个人有一所房子还是一所房子有居民请尝试在此处考虑关系名称。 Do they OWN the house, LIVE AT the house or what? 他们是自己的房子,还是住在房子里?

Person--{has}-->house
Person--{livesat}-->house
Person--{owns}-->house
House--{has}-->occupant

They're all slightly different relationships. 他们都是稍微不同的关系。 Apply this thinking to your own model and go for what you think's best. 将这种想法应用到您自己的模型中,并努力做到最好。 I'm not a fan of "by" relationships, eg house--{ownedby}-->person as they're simply traversing an "own" relationship backwards and are better expressed that way around. 我不喜欢“ by”关系,例如房屋-{ownby}-> person,因为他们只是简单地向后遍历“ own”关系,并且更好地表达了这种关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM