遍历断开连接的图并创建标识符

Traversing disconnected graphs and creating indentifiers

我正在尝试创建一个客户身份图来跨设备跟踪客户,无论是登录还是注销。

目前,我正在尝试做两件事:

  1. 对于每个断开连接的图,在唯一生成的图之间创建映射 密钥和实体(adobe、潜在客户、帐户、结帐)。

    1. 例如,底部图表将随机选择一个实体作为唯一键。如果我们选择 adobe,我们将创建一个新值“adobe:”并将其用作识别此断开连接图的键。也许我们可以遍历整个断开连接的图并将值“adobe:”设置为 属性.
  2. (nice to have) 能够处理 两个不同帐户可能使用相同 ip_address 的情况。 例如,顶部图表应该有 2 个唯一生成的键。

我对 Gremlin 还很陌生,但我了解图形遍历的基础知识。不知道从哪里开始,所以任何见解表示赞赏!

我在下面创建了一个简化版本。 Gremlify link 也将允许代码执行。

https://gremlify.com/jmg2fzo34om/3

听起来好像您在进行某种形式的社区检测,或者可能只是想识别 components of the graph. With Gremlin, this is likely best done with a Graph Computer (OLAP) and perhaps the connectedComponent() step:

gremlin> g.withComputer().
......1>   V().connectedComponent().
......2>         with(ConnectedComponent.propertyName, 'component').
......3>   elementMap().
......4>   order().by('component')
==>[id:0,label:account,component:0,account_id:1]
==>[id:2,label:lead,component:0,lead_id:1]
==>[id:6,label:account,component:0,account_id:3]
==>[id:8,label:checkout,checkout_id:1,component:0]
==>[id:10,label:lead,component:0,lead_id:2]
==>[id:12,label:ip_addr,component:0,ip_addr:1.1.1.1]
==>[id:16,label:page,page_id:1,component:14]
==>[id:18,label:lead,component:14,lead_id:4]
==>[id:4,label:adobe,component:14,adobe_id:1]
==>[id:14,label:ip_addr,component:14,ip_addr:3.3.3.3]

您可以在没有图形计算机 (OLTP) 的情况下使用 Gremlin 来查找连接的组件,但除非您有一个非常小的图形,否则它的性能就不会那么好。如果您有兴趣了解更多相关信息,可以找到更详细地介绍该主题的 Gremlin Recipe here