gremlin

How can I get an exclusive subgraph from a vertex?

本小妞迷上赌 提交于 2019-12-24 10:56:15
问题 I've recently had to change from using Cypher to Gremlin and I'm trying to convert a query that allowed a user to 'delete' a node and all of the subgraph nodes that would be affected by this. It wasn't actually removing nodes but just adding a 'DELETED' label to the affected nodes. I can get a subgraph in Gremlin using: g.V(nodeId).repeat(__.inE('memberOf').subgraph('subGraph').outV()).cap('subGraph') but this doesn't take into account any nodes in the subgraph that might have a route back

Is it possible to get the shortest path with traversal cost by using Cypher or Gremlin?

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:53:46
问题 I know it is possible to get the shortest path of minimum number of nodes by using Cypher and Gremlin? How about getting a path with minimum traversal cost? One of the example I can think of is the bus route. Some routes may have less bus stops (nodes) but need longer time (cost) to travel from one stop to another, some are reverse. Is it possible to get the shortest path with minimum travel time by using Cypher or Gremlin? 回答1: See this other question for more on shortest paths. In answer to

Connecting gremlin CLI to a remote tinkerpop gremlin-server

只谈情不闲聊 提交于 2019-12-24 08:17:27
问题 Using gremlin-javascript , I'm connecting to a remote server using: const gremlin = require('gremlin') const Graph = gremlin.structure.Graph const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection const graph = new Graph() const g = graph .traversal() .withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin')) From the gremlin CLI, I can setup a TinkerGraph using gremlin> graph = TinkerGraph.open() gremlin> g = graph.traversal() However, I'd like to connect to my Graph

Return nodes who are connected by a common set of nodes

ⅰ亾dé卋堺 提交于 2019-12-24 07:37:15
问题 Is there a way in Neo4j, using either cypher or gremlin, to return a list of nodes that have a common set of nodes between them? An example would be Person1-[KNOWS]->Friend1 Person1-[KNOWS]->Friend2 Person1-[KNOWS]->Friend3 Person2-[HATES]->Friend2 Person2-[HATES]->Friend3 I want to start at Person1 and say, "Find me the people who hate all the people I know", which should return Person2 since Person1 knows Friend2,Friend3 and Person2 hates Friend2,Friend3 . I've started by finding the

how to add a vertex only if it doesn't exist and continue this single traversal with other graph mutations?

给你一囗甜甜゛ 提交于 2019-12-24 07:10:03
问题 Currently I have this gremlin/groovy code: if(!g.V().has("Number","number","3").hasNext()) { g.addV("Number").property("number","3") } Is it possible to have the same result without using multiple traversals? I tried this and it doesn't work (it doesn't add either Number or User vertices) g.V().choose(has("Number","number", "3"), addV("Number").property("number", "3"), has("Number","number", "3") ).as("number") .addV("User").property("uuid","test uuuid") .forEachRemaining(System.out::println)

Calling a gremlin script from python program that uses Bulbs

ε祈祈猫儿з 提交于 2019-12-24 06:44:28
问题 I am using TitanGraphDB + Cassandra.I am starting Titan as follows cd titan-cassandra-0.3.1 bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties I have a Rexster shell that I can use to communicate to Titan+Cassandra above. cd rexster-console-2.3.0 bin/rexster-console.sh I am attempting to model a network topology using Titan Graph DB.I want to program the Titan Graph DB from my python program.I am using bulbs package for that. I create three types of vertices

Calling a gremlin script from python program that uses Bulbs

微笑、不失礼 提交于 2019-12-24 06:44:14
问题 I am using TitanGraphDB + Cassandra.I am starting Titan as follows cd titan-cassandra-0.3.1 bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties I have a Rexster shell that I can use to communicate to Titan+Cassandra above. cd rexster-console-2.3.0 bin/rexster-console.sh I am attempting to model a network topology using Titan Graph DB.I want to program the Titan Graph DB from my python program.I am using bulbs package for that. I create three types of vertices

Gremlin filter by count

夙愿已清 提交于 2019-12-24 05:49:37
问题 With the usage of this query in CosmosDB Gremlin API: g.V().has('person', 'name', 'John').as('his') .out('bought').aggregate('self') .out('made_by') I have next output: [ { "id": "100", "label": "brand", "type": "vertex", "properties": { "name": [ { "id": "233b77e7-7007-4c08-8930-99b25b67e493", "value": "Apple" } ] } }, { "id": "100", "label": "brand", "type": "vertex", "properties": { "name": [ { "id": "233b77e7-7007-4c08-8930-99b25b67e493", "value": "Apple" } ] } }, { "id": "101", "label":

Gremlin filter by count

ε祈祈猫儿з 提交于 2019-12-24 05:49:12
问题 With the usage of this query in CosmosDB Gremlin API: g.V().has('person', 'name', 'John').as('his') .out('bought').aggregate('self') .out('made_by') I have next output: [ { "id": "100", "label": "brand", "type": "vertex", "properties": { "name": [ { "id": "233b77e7-7007-4c08-8930-99b25b67e493", "value": "Apple" } ] } }, { "id": "100", "label": "brand", "type": "vertex", "properties": { "name": [ { "id": "233b77e7-7007-4c08-8930-99b25b67e493", "value": "Apple" } ] } }, { "id": "101", "label":

Cycles in Gremlin/Cypher

99封情书 提交于 2019-12-24 04:07:09
问题 I'm making a presentation about how some elements looks in Neo4j's Cypher and Titan's Gremlin i.e. add new vertex, look for relation etc. I have a problem with looking for cyclec. Is there any function in these 2 languages which can return a cycles i.e. for given vertex? 回答1: Here's how you do it in Gremlin: gremlin> g = TinkerGraphFactory.createTinkerGraph() ==>tinkergraph[vertices:6 edges:6] gremlin> g.v(2).addEdge("knows", g.v(6)) ==>e[0][2-knows->6] gremlin> g.v(6).addEdge("knows", g.v(1)