Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display all nodes on screen in neo4j

Tags:

neo4j

I have a almost 5000 nodes of Recipes and 5 nodes of Meal_Types in neo4j database. Right now there is no relationship between them. I am running CQL below:

MATCH (n) RETURN n LIMIT 100000

This is running fine, but it is returning node related to Recipes only. There may be something hidden, I mean there might be nodes related to Meal_Types but as they are in same color it is very hard to differentiate them.

So is there a way to bring all nodes to dispaly with different colors respectively?

like image 437
Muhammad Yaseen Khan Avatar asked Jul 21 '16 10:07

Muhammad Yaseen Khan


2 Answers

Since you write about "display" and "colors", I assume you're writing about the Neo4j browser.

Your query might limit its results to the first 100000, but the browser will actually display much less nodes, with a default number of 300. You can change that value using the following command in the browser:

:config initialNodeDisplay: 1000

or through the settings pane on the bottom left (see the "Graph Visualization" section).

Since you only have 5 Meal_Types nodes, vs 5000 Repices, it's unlikely they'll be part of any partial result. You can bias the result by ordering on the label, since Meal_Type will sort alphabetically before Recipes:

MATCH (n)
RETURN n
ORDER BY head(labels(n))
LIMIT 300

That way, you don't need to display more nodes (since you can't zoom out, it's pretty useless anyway) and you'll always get your 5 Meal_Types.

like image 151
Frank Pavageau Avatar answered Nov 13 '22 08:11

Frank Pavageau


You can change the styling of the output in the neo4j browser as described here:

https://neo4j.com/developer/guide-neo4j-browser/#_styling_neo4j_browser_visualization

However, there is a limit for the number of nodes/relationships that can be displayed. So you will likely not see all 5000 Recipe nodes and all 5 Meal_Type nodes but rather the first N nodes returned from your query.

Rendering of large graphs is really difficult :)

like image 33
Martin Preusse Avatar answered Nov 13 '22 06:11

Martin Preusse