Gremlin 给定两个特定顶点,如何在Titan中获得它们之间的子图?
我们有数百万个顶点和一千万条边来形成一个有向图。有人知道如何在Titan中的两个给定顶点之间获取子图吗?TinkerPop提供了两种子图生成方法:Gremlin 给定两个特定顶点,如何在Titan中获得它们之间的子图?,gremlin,titan,nosql,Gremlin,Titan,Nosql,我们有数百万个顶点和一千万条边来形成一个有向图。有人知道如何在Titan中的两个给定顶点之间获取子图吗?TinkerPop提供了两种子图生成方法: 还有 有 使用子图步骤将子图“弹出”到单独的图实例中。在下面的示例中,您可以看到图形“g”是如何被子图形化为“已知”边的新图形实例的: 在只想遍历图的子集的情况下,可以使用子图策略: gremlin> graph = TinkerFactory.createTheCrew() ==>tinkergraph[vertices:6 edges
子图
步骤将子图“弹出”到单独的图实例中。在下面的示例中,您可以看到图形“g”是如何被子图形化为“已知”边的新图形实例的:
在只想遍历图的子集的情况下,可以使用子图
策略:
gremlin> graph = TinkerFactory.createTheCrew()
==>tinkergraph[vertices:6 edges:14]
gremlin> g = graph.traversal().withStrategies(SubgraphStrategy.build().
vertices(or(hasNot('location'),properties('location').count().is(gt(3)))).
edges(hasLabel('develops')).
vertexProperties(or(hasLabel(neq('location')),hasNot('endTime'))).create())
==>graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
gremlin> g.V().valueMap(true)
==>[id:1,label:person,name:[marko],location:[santa fe]]
==>[id:8,label:person,name:[matthias],location:[seattle]]
==>[id:10,label:software,name:[gremlin]]
==>[id:11,label:software,name:[tinkergraph]]
gremlin> g.E().valueMap(true)
==>[id:13,label:develops,since:2009]
==>[id:14,label:develops,since:2010]
==>[id:21,label:develops,since:2012]
根据你问题的标题,听起来你只需要两个顶点之间有边的图。我想这听起来像是你想使用子图步骤。当然,要得到这样的结果似乎更容易:
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(1).bothE().where(otherV().hasId(2))
==>e[7][1-knows->2]
使边列表在某种意义上构成子图,特别是在两个已知顶点的情况下。TinkerPop提供了两种子图方法:
还有
有
使用子图
步骤将子图“弹出”到单独的图实例中。在下面的示例中,您可以看到图形“g”是如何被子图形化为“已知”边的新图形实例的:
在只想遍历图的子集的情况下,可以使用子图
策略:
gremlin> graph = TinkerFactory.createTheCrew()
==>tinkergraph[vertices:6 edges:14]
gremlin> g = graph.traversal().withStrategies(SubgraphStrategy.build().
vertices(or(hasNot('location'),properties('location').count().is(gt(3)))).
edges(hasLabel('develops')).
vertexProperties(or(hasLabel(neq('location')),hasNot('endTime'))).create())
==>graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
gremlin> g.V().valueMap(true)
==>[id:1,label:person,name:[marko],location:[santa fe]]
==>[id:8,label:person,name:[matthias],location:[seattle]]
==>[id:10,label:software,name:[gremlin]]
==>[id:11,label:software,name:[tinkergraph]]
gremlin> g.E().valueMap(true)
==>[id:13,label:develops,since:2009]
==>[id:14,label:develops,since:2010]
==>[id:21,label:develops,since:2012]
根据你问题的标题,听起来你只需要两个顶点之间有边的图。我想这听起来像是你想使用子图步骤。当然,要得到这样的结果似乎更容易:
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(1).bothE().where(otherV().hasId(2))
==>e[7][1-knows->2]
让边列表在某种意义上构成一个子图,特别是在两个已知顶点的情况下。感谢您的回复,Stephen Mallette!是否可以更改为Titan 0.5.4的命令?目前,我们没有升级到Titan 1.0的计划。TinkerPop 2.x和Titan 0.5.x中没有内置子图函数。你必须写下你自己的方法。您可以很容易地找到两个顶点之间的边:g.v(1).bothE.as('x')。bothV.retain([g.v(3)]。back('x')
从Good复制而来!我们将更详细地尝试。顺便问一下,你知道如何在土卫六的有向图中得到所有的圈吗?有内置函数吗?还是我们应该编写自己的方法?感谢您的回复,Stephen Mallette!是否可以更改为Titan 0.5.4的命令?目前,我们没有升级到Titan 1.0的计划。TinkerPop 2.x和Titan 0.5.x中没有内置子图函数。你必须写下你自己的方法。您可以很容易地找到两个顶点之间的边:g.v(1).bothE.as('x')。bothV.retain([g.v(3)]。back('x')
从Good复制而来!我们将更详细地尝试。顺便问一下,你知道如何在土卫六的有向图中得到所有的圈吗?是否有内置函数,或者我们应该编写自己的方法?