cypher

Neo4J - Traveling Salesman

一世执手 提交于 2019-12-21 06:57:31
问题 I'm trying to solve an augmented TSP problem using a graph database, but I'm struggling. I'm great with SQL, but am a total noob on cypher. I've created a simple graph with cities (nodes) and flights (relationships). THE SETUP: Travel to 8 different cities (1 city per week, no duplicates) with the lowest total flight cost. I'm trying to solve an optimal path to minimize the cost of the flights, which changes each week. Here is a file on pastebin containing my nodes & relationships. Just run

Neo4j / Cypher: create relationship if certain condition is met

ⅰ亾dé卋堺 提交于 2019-12-21 05:17:20
问题 I am doing a sum operation in my graph DB: I compare a couple of nodes, calculate a figure to represent how similar certain regions of the graph are and if that figure is big enough, I want to create a relationship between the nodes. I've got a query which does all that, except for the check if the figure is big enough; it currently also creates similarity relationships whose similarity score is 0 - and I don't want that. My full cypher query is somewhat longish, so I've simplified it for

Depth in custom Cypher queries with OGM always 0?

邮差的信 提交于 2019-12-21 05:04:33
问题 I'm currently evaluating OGM / Spring Data Neo4j for a use case and came upon the following problem: When executing a custom Cypher query either via Spring Data @Query annotation or directly via the Neo4j Session , the result contains only the nodes directly queried for and not the related nodes (relationships are null in the resulting node objects). I.e. the depth for these queries seems to be 0 and not 1, as I would have expected from the docs. How can I execute a custom Cypher query via

Visualizing graph database

☆樱花仙子☆ 提交于 2019-12-21 04:51:27
问题 Assuming i am working with neo4j , the only way i can think of that would visualize my mock up data is to generate cypher code and paste it into neo4j's data browser Is there another (better, simplier?) way one can use to create visualization without using cypher ? Generating cypher code seems like a complex enough task by itself. Writing tests is of course another way of making sure relationships are set up right, but as i am learning the system, i'd like to visually see things to make sure

Deleting all nodes and relationships in neo4j using cypher exceeds heap space

旧街凉风 提交于 2019-12-20 12:15:28
问题 I have been trying to run this query as recommended in the neo4j google group and in other sources online: START n = node(*) MATCH n-[r?]-() WHERE ID(n)>0 DELETE n, r; in order to delete all nodes and relationships between tests. When I do so from the console, I run out of java heap space. When I do so from python (using the newish graph_db.clear(), which appears uses the same query), I get a "SystemError: None" which, I assume, is the same java heap space error. I have a database with 500k

neo4j cypher nested collect

匆匆过客 提交于 2019-12-20 10:41:32
问题 Imagine a photo album schema w/ Users, Albums, and Photos: User -[owns]-> Album -[contains]-> Photo Can I do a nested collect to get Photos nested in Albums, and Albums nested in User? I'd like results similar to: { "users": [ { "name": "roger dodger", "albums": [ { "album": "album1", "photos": [ {"url": "photo1.jpg"}, {"url": "photo2.jpg"} ] } ] } ] } This seems close but I could not modify it to suit my needs: Nested has_many relationships in cypher (Could the problem be that neo4j 2.0 web

Modeling conditional relationships in neo4j v.2 (cypher)

空扰寡人 提交于 2019-12-20 05:48:11
问题 I have two related problems I need help with. Problem 1: How do I model a conditional relationship? I want my data to indicate that when test CLT1's "Result" property = "High", CLT1 has relationship to Disease A. If I take a node-centric approach, I imagine that the code might look something like... (CLT 1 {Result: "High"}) -[:INDICATES] -> (Disease A) Further, when CLT1's "Result" property = "Low", CLT1 has a relationship to Disease B (CLT 1 {Result: "Low"}) -[:INDICATES] -> (Disease B)

Optimize Neo4j Cypher query

≯℡__Kan透↙ 提交于 2019-12-20 04:18:29
问题 What I'm doing is to get all profiles * who has a specific directed relation to a users profile * and if those have an alternate profile * get those in case the users alternate profile * has a relation to it. I also need the direction of the relations. My problem is, with about 10000 nodes it takes about 5 seconds to get data. I have auto index on nodes and relationships. This is how my nodes are related: User-[:profile]->ProfileA-[:related]->ProfileB<-[?:me]->ProfileB2<-[?:related]-ProfileA2

Neo4j Show Only Specific Relations in the Browser Graph View

血红的双手。 提交于 2019-12-20 03:50:24
问题 I have this Cypher query: MATCH (i:Issue {name:"SN-229"})-[d:ON_DATE]->(s:Stage) RETURN i,(MAX(d.long)-MIN(d.long)+1) AS Days,s and I get these results in the Neo4j Browser's Text view Which are the answers I want. But when I view the result in the Neo4j Browser's Graph view, it insists on displaying the individual dates in the relationships!?!? What query could I write to show me this "ideal" Graph view (the displayed dates are the MIN(d.long) dates) or at least just display the relationship

Neo4j how to delete nodes recursively from some start node

有些话、适合烂在心里 提交于 2019-12-20 03:23:54
问题 In my Neo4j database I have a following entities: @NodeEntity public class Product { private final static String CONTAINS = "CONTAINS"; private final static String DEFINED_BY = "DEFINED_BY"; private final static String VOTED_FOR = "VOTED_FOR"; private final static String PARENT = "PARENT"; private final static String CREATED_BY = "CREATED_BY"; @GraphId private Long id; @RelatedTo(type = PARENT, direction = Direction.INCOMING) private Product parent; @RelatedTo(type = CONTAINS, direction =