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.

Cypher Query to show Node Labels in Graph

sebyid
Node Link

Hello

So i have a simple cypher query that returns the below graph image. However, the graph at some locations contains NO node labels and in other locations DOES contain node labels.

I recall that there is a cypher query statement that can be implemented to force all node labels to show in the graph? I was wondering if someone could assist me with this query.

2 REPLIES 2

luanne
Node Clone

Not aware of a Cypher query for this, but you can pick the right property to show for the labels that do not have a value displayed from the browser/Neo4j desktop browser

There are a few things that could be happening here, but to be more precise, we'll need the Cypher query you're running.

  1. The text on a node in the Browser defaults to the value of the name property of that node.
  2. In the browser, you can select which property will be used for the text, for specific Labels.

The nodes which have no text have no value to display. It's that simple.

Breakdown

CREATE (a:Example {name:'this', name2: 'that'})

2X_1_1085abf00ae86357a14e7e63c492ab40427d5dff.png

Click the Label at the top
2X_e_e673e0b65ed2ee0752ea064758c1815322fc0898.png

And then chose a property at the bottom:
2X_6_67d8a9fc6f422ad959fc41f41461961673ee30f2.png

2X_2_226a87bd5355b5ec7601238c9c885f05e50a8aa7.png

If you delete that property...
2X_4_4d6cc93db2eb7031164982b51f89ecbba25017e0.png

Showing labels in your graph.

The only way to do that reliably, without mutating your data, is with virtual nodes.
https://neo4j.com/docs/labs/apoc/current/virtual/
That's a deep rabbit-hole, so I'm not going into it.

The other thing you can do is just create a new property, and set it to the string of your labels...

MATCH (a)
SET a :Ex2
SET a.nameLabel = REDUCE(res = "", x in labels(a) | x + ", " + res)
RETURN a

2X_8_8f6608567dd230cd1647a2b4d9eee57d2dcec0c4.png