Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide unwanted relationships between nodes in Neo4j

Tags:

I'm new in Neo4j and I have a weird requirement.

I have some node

CREATE (a:node {title:1}) CREATE (b:node {title:2}) CREATE (c:node {title:3}) CREATE (d:node {title:4}) 

and multiple relationships between them:

CREATE (a)-[:RELATES{jump:[1]}]->(b) CREATE (b)-[:RELATES{jump:[1]}]->(c) CREATE (c)-[:RELATES{jump:[1]}]->(d) CREATE (a)-[:RELATES{jump:[2]}]->(c) CREATE (c)-[:RELATES{jump:[2]}]->(d) CREATE (d)-[:RELATES{jump:[1]}]->(b) CREATE (a)-[:RELATES{jump:[3]}]->(d) CREATE (d)-[:RELATES{jump:[3]}]->(c) CREATE (c)-[:RELATES{jump:[3]}]->(b) 

The graph and the relationship are shown here: enter image description here

I want to check the graph such that only those relationships should be visible which I'm interested in. Now when I do something like this: MATCH (a)-[r]->(b) WHERE 1 IN r.jump RETURN a,b

I get the something like:

enter image description here

Is there a way where I can hide(not delete) the not relevant relationships while displaying the graph? May be something like this(edited on Image tool):

enter image description here

PS: Let Grey be white.

like image 635
kishoredbn Avatar asked Jun 02 '16 23:06

kishoredbn


People also ask

How do I delete all relationships in Neo4j?

Deleting Nodes and Relationships Deleting all nodes and relationships in a Neo4j database is very simple. Here is an example that does just that: MATCH (n) DETACH DELETE n; The DETACH keyword specifies to remove or “detach” all relationships from a particular node before deletion.

How are relationships stored in Neo4j?

Properties are stored as a linked list of property records, each holding a key and value and pointing to the next property. Each node and relationship references its first property record. The Nodes also reference the first relationship in its relationship chain. Each Relationship references its start and end node.

Can u relabel node in Neo4j?

You can change the nodes associated with a label but you can't change the type of a relationship.

How do you create a relationship between existing nodes in Neo4j?

To create a relationship between two nodes, we first get the two nodes. Once the nodes are loaded, we simply create a relationship between them. The created relationship is returned by the query.


2 Answers

In neo4j 3.2.1 this feature has been relocated to the bottom left corner, under the gear icon: "Connect result nodes" (checked by default, thus returning all relationships between nodes included in the result).

uncheck the box

like image 92
VeraKozya Avatar answered Oct 10 '22 17:10

VeraKozya


By default the Neo4j Browser uses an "Auto-Complete" feature to show all relationships that exist between nodes in the visualization. You can change this by toggling the "Auto-Complete" button in the Neo4j browser:

enter image description here

This will exclude any relationships not explicitly returned in the Cypher query from the visualization.

Note that you will need to explicitly return the relationships you are interested in. So your query becomes:

MATCH (a)-[r]->(b)  WHERE 1 IN r.jump  RETURN a,r,b 
like image 40
William Lyon Avatar answered Oct 10 '22 16:10

William Lyon