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.

Coloring nodes in Neo4j depending on property

This is the question I get asked more often: Can I color nodes in Neo4j Desktop and Bloom according to their properties?

Would you recommend this solution from stackoverflow or only under certain conditions?


stackoverflow

7 REPLIES 7

For quick visualisations I use virtual nodes and relationships as described in your screenshot – this is not only great for colouring things differently, but also to collapse data to a more comprehensible presentation.

E.g. in a finance related DB I have accounts and payments as separate nodes like (Account)-[has sent]->(Payment)-[has received]->(Account) but presenting it it is easier to show (Account)-[payment]->(Account).

Another angle is to look at Labels, and if there is a need to colour nodes differently in presentation, it might call for "upgrading" the property in question to a Label?

E.g. in my database all transactions have a Transaction label, but also a "TransactionType" label.

shan
Graph Buddy

I needed to do the same for my problem and I ended up with two alternative solutions:

  1. Add labels to nodes based on their properties:
match (n:Person)
with distinct n.gender as gender, collect(distinct n) as persons
call apoc.create.addLabels(persons, [apoc.text.upperCamelCase(gender)]) yield node
return *
  1. Use https://github.com/neo4j-contrib/neovis.js/. The community property determines the color of the node.

The first one is easier as you don't need another tool.

For Bloom, stay tuned for the upcoming version

Is this gonna be a Christmas present? Or do we have to be patient until 2020?

Unfortunately in early 2020.

I have something like the following:

match (n) detach delete n;

LOAD CSV WITH HEADERS FROM 'file:///data-assets.csv' AS data
Create (:Data {id: data.Id, dataName: data.Name, dataType: data.Type});

LOAD CSV WITH HEADERS FROM 'file:///data-links.csv' AS links
match (d1:Data {id:links.Source}), (d2:Data {id:links.Target})
CREate (d1)-[:Feeds]->(d2);

And I fail to connect it to your solution here. Any tips?

@shan this is amazing, I worked it out using a gds.wcc.create algorithm output.

My followup question is this: given I have tens of distinct communities, colors of all nodes hasn't changed, even when I see that the label is registered successfully

MATCH (n:`cluster_47`) RETURN n LIMIT 25

what am I doing wrong?