cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Ways to represent relationship nodes in Neo4j using neovis.js

sucheta
Graph Buddy

Hi,

I was finding it difficult to create a relationship using Neovis.js that i have integrated in my angular and nodejs project. So Michael Hunger asked me to use a query -

    MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100.

(Now this above query worked but only worked but it works for a certain limit. And for which i get an error and i have raised a new topic for it.)

So now following the guide above, i created a query -

MATCH (n) OPTIONAL MATCH (corebanking:Dept)-[r]->(m),(accountsummary:API)-[i]->(j) RETURN 
n,corebanking,accountsummary, r,m,i,j LIMIT 40

And the output here has an issue.

The output on my Neo4j desktop version is -

2X_0_0225dd0c9c34fda798cd4eb3558959ebd1022f86.png

And my output using Neovis.js code is-

Here there is a small error. The two blue colored nodes - Banking donot show any relationship. Whereas in the Desktop version / the picture that i showed first has a relationship.

Please help here.

1 ACCEPTED SOLUTION

William_Lyon
Graph Fellow

It seems the relationships connecting the blue Banking nodes are not captured in your query to populate the neovis.js visualization because the LIMIT is excluding them from being returned. Note that these relationships show up in the Neo4j Browser for the same query because of the Brower's "connect result nodes" feature. If you go into Neo4j Browser settings and un-check "connect result nodes" I suspect you will see the same visualization as the one in neovis.js.

What you need to do is change the query so that all the data (nodes, relationships, paths, etc) you wish to visualize are explicitly returned by the Cypher query. What exactly are you trying to visualize? It's typically not best to try to visualize the entire graph with tools like neovis.js, only a subset.

If you want to visualize all relationships for a set of given set of nodes you could try using the limit on the nodes, and then matching on all their relationships. Like this:

// some query to identify the nodes you are interested in
MATCH (n) 
WITH n LIMIT 10

// get all relationships for these nodes
OPTIONAL MATCH (n)-[r]-(m)
RETURN n, r, m

View solution in original post

2 REPLIES 2

William_Lyon
Graph Fellow

It seems the relationships connecting the blue Banking nodes are not captured in your query to populate the neovis.js visualization because the LIMIT is excluding them from being returned. Note that these relationships show up in the Neo4j Browser for the same query because of the Brower's "connect result nodes" feature. If you go into Neo4j Browser settings and un-check "connect result nodes" I suspect you will see the same visualization as the one in neovis.js.

What you need to do is change the query so that all the data (nodes, relationships, paths, etc) you wish to visualize are explicitly returned by the Cypher query. What exactly are you trying to visualize? It's typically not best to try to visualize the entire graph with tools like neovis.js, only a subset.

If you want to visualize all relationships for a set of given set of nodes you could try using the limit on the nodes, and then matching on all their relationships. Like this:

// some query to identify the nodes you are interested in
MATCH (n) 
WITH n LIMIT 10

// get all relationships for these nodes
OPTIONAL MATCH (n)-[r]-(m)
RETURN n, r, m

sucheta
Graph Buddy

Thanks William,

I am getting the relationships as you said.

But can we get as clean, sharp and beautiful nodal graph that we get in our Neo4j browser/desptop version ..into Neovis.js output ?

Here the output graph is missing its nodal name inside and also doesn't look as good as those in Neo4j tool