neo4j

shortest path between 2 nodes through waypoints in neo4j

ε祈祈猫儿з 提交于 2021-02-08 10:11:06
问题 I have a graph in neo4j where a node represents a city and a relationship represents roads connecting the cities. The relationships are weighted and have a property called 'distance'. I want to find the shortest (least weighted path) between two cities A and B. This is easily done using Dijkstra's algorithm. The tricky part is that I have a set of cities which are to be covered in the path from A to B. In other words, the path from A to B should cover all the waypoints, the order doesn't

Cypher temp relationship

浪子不回头ぞ 提交于 2021-02-08 08:24:08
问题 I'm trying to combine / merge a path into a new relationship. The problem is that I'm not interested in storing it but rather return it as a result of a cypher query. Lets say I have something like this: (a)-[:CALLS_METHOD]->(b)-[:RETURNS_TYPE]->(c) How can I create a temporary relationship like this one: (a)-[:DEPENDS_ON]->(c) Only for a result of that particular query, so that I don't have to store it. Because I'm really only interested in the dependency from a to c and not the details

Cypher temp relationship

半世苍凉 提交于 2021-02-08 08:23:12
问题 I'm trying to combine / merge a path into a new relationship. The problem is that I'm not interested in storing it but rather return it as a result of a cypher query. Lets say I have something like this: (a)-[:CALLS_METHOD]->(b)-[:RETURNS_TYPE]->(c) How can I create a temporary relationship like this one: (a)-[:DEPENDS_ON]->(c) Only for a result of that particular query, so that I don't have to store it. Because I'm really only interested in the dependency from a to c and not the details

Creating relationships based on array values in Neo4j

二次信任 提交于 2021-02-07 23:45:37
问题 I have two nodes representing two people: (:Person {name:"John Smith"}) (:Person {name:"Jane Doe"}) Then I have a third node representing an article coauthored by these two people: (:Article {title:"Some_article"}, {Coauthor:["John Smith", "Jane Doe"]}) My question is: Can I create a relationship between these nodes based on matching the names? Something like this: MATCH (n1:Person {name:"Jane Doe"}) MATCH (n2:Article{Coauthor:"Jane Doe"}) CREATE (n2)-[:AUTHORED_BY]->(n1) Is this possible or

Return All Nodes in Shortest Path as Object List

假如想象 提交于 2021-02-07 07:17:34
问题 I have the following Cypher Query which works fine in the Neo4j 2.0.0. MATCH (ab:Point { Latitude: 24.96325, Longitude: 67.11343 }),(cd:Point { Latitude: 24.95873, Longitude: 67.10335 }), p = shortestPath((ab)-[*..150]-(cd)) RETURN p The following Query in Neo4jClient gives the error: Function Evaluation Timed out. var pathsQuery = client.Cypher .Match("(ab:Point { Latitude: 24.96325, Longitude: 67.11343 }),(cd:Point { Latitude: 24.95873, Longitude: 67.10335 }), p = shortestPath((ab)-[*..150]

Cypher 'Node Already Exists' issue with MERGE

落花浮王杯 提交于 2021-02-06 09:12:40
问题 I am preplexed on why I am getting an issue with this Cypher statment when I have a unique constraint on the address of the location node but am using a merge which should find that if it exists and only return the id for the rest of the statment. What am I missing? Here is my statement: MERGE(l:Location{location_name:"Starbucks", address:"36350 Van Dyke Ave", city: "Sterling Heights",state: "MI", zip_code:"48312",type:"location",room_number:"",long:-83.028889,lat:42.561152}) CREATE(m:Meetup

Cypher 'Node Already Exists' issue with MERGE

十年热恋 提交于 2021-02-06 09:12:34
问题 I am preplexed on why I am getting an issue with this Cypher statment when I have a unique constraint on the address of the location node but am using a merge which should find that if it exists and only return the id for the rest of the statment. What am I missing? Here is my statement: MERGE(l:Location{location_name:"Starbucks", address:"36350 Van Dyke Ave", city: "Sterling Heights",state: "MI", zip_code:"48312",type:"location",room_number:"",long:-83.028889,lat:42.561152}) CREATE(m:Meetup

Cypher 'Node Already Exists' issue with MERGE

…衆ロ難τιáo~ 提交于 2021-02-06 09:12:05
问题 I am preplexed on why I am getting an issue with this Cypher statment when I have a unique constraint on the address of the location node but am using a merge which should find that if it exists and only return the id for the rest of the statment. What am I missing? Here is my statement: MERGE(l:Location{location_name:"Starbucks", address:"36350 Van Dyke Ave", city: "Sterling Heights",state: "MI", zip_code:"48312",type:"location",room_number:"",long:-83.028889,lat:42.561152}) CREATE(m:Meetup

Can a Neo4j identifier start with an integer?

这一生的挚爱 提交于 2021-02-05 08:29:27
问题 MATCH (p:Product {id:'19134046594'})-[r]-> (o:Attributes {4g:'network'}) return o I received this exception: Exception in thread "main" java.lang.RuntimeException: org.neo4j.driver.v1.exceptions.ClientException: Invalid input ':': expected an identifier character, whitespace or '}' (line 1, column 66 (offset: 65)) It's complaining about '4g'. Is '4g' an invalid property key identifier in neo4j? How to work around the issue? 回答1: You can use the backtick (`) character to quote property names

Neo4j Cypher: Find common nodes between a set of matched nodes

ぃ、小莉子 提交于 2021-02-05 07:37:50
问题 Very similar to the question posted here I have the following nodes: Article and Words. Each word is connected to an article by a MENTIONED relationship. I need to query all articles that have common words where the list of common words is dynamic. From the clients perspective, I am passing back a list of words and expecting back a results of articles that have those words in common. The following query does the job WITH ["orange", "apple"] as words MATCH (w:Word)<-[:MENTIONED]-(a:Article)-[