liveBook · Manning

Node label

As explained in Graph Algorithms for Data Science

A node label is a categorical marker attached to a graph node that identifies its type, role, or entity class.

A node label is a type marker attached to a graph node. It says what role the node plays in the domain, such as Person, Organization, User, or Tweet. Labels differ from properties: a label categorizes the node, while properties hold values such as a name, ID, or creation time. section 2.2 section 2.2.1

(:Person {name:"Thomas"})

In Cypher, parentheses represent a node and a colon introduces its label. This pattern describes a Person node with a name property. section 2.2

Choose labels that match the data as closely as possible. A social-media graph may use User and Tweet rather than one broad Post label, because different platforms and post types can require different properties and relationships. Specific labels keep the model closer to the domain and make queries simpler. section 2.3.2

Modeling a follower network

When every node represents a Twitter user, give each node the User label and store its handle or ID as a property for disambiguation. Because only one node label is present, this is a monopartite network. The FOLLOWS relationship supplies the interaction between those User nodes. section 2.3.1

A node can carry more than one label when each label contributes a distinct classification:

  • Use a primary domain label such as Person to identify what the node represents. section 2.2.1
  • Add secondary labels such as Student or Employee to group nodes for easier retrieval. section 3.1.4
  • Keep multiple labels semantically orthogonal, rather than assigning labels with the same or closely overlapping meaning. section 3.1.4
  • Avoid placing more than a couple of labels on one node for modeling and performance reasons. section 3.1.4

Use Cypher's SET clause to add a label to an existing node. Labels can also support derived groupings: after calculating a customer's funnel stage, assign a corresponding secondary label so that subset is easy to match later. Creating nodes without labels is not advisable. section 3.1.4 section 3.4

In a graph schema drawing, each node label is commonly shown as one representative node, with that label's properties attached to it. This makes User and Tweet visible as separate node types and shows self-loops for relationships that connect nodes of the same label. LPG schema notation has no official standard. section 2.3.4

How Graph Algorithms for Data Science covers it

How deep it goes
Defines labels, contrasts them with properties, and demonstrates Cypher syntax, label updates, and schema representation.
Examples
Uses Person and Organization nodes, Twitter User and Tweet nodes, follower networks, and Student or Employee secondary labels.
What it assumes
Teaches node labels from basic Cypher node notation without assuming graph-theory expertise.
What you can do after
Apply it via Cypher to model typed nodes and add secondary labels for retrieval.
How it connects
Connects labels to properties, relationship types, labeled-property graphs, graph schemas, monopartite networks, and bipartite networks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.