A graph pattern is Cypher syntax that describes nodes, relationships, and the structure connecting them. Node patterns use parentheses; labels, properties, and variables can narrow the nodes of interest. Relationship patterns connect node patterns and can include a type and direction. The same description can represent data to find, create, merge, or delete. section 3.1.1 section 3.1.2 section 3.1.6
For example, `(p:Person {name:'Satish'})` describes a Person node whose name is Satish. In `MATCH`, this is a request to retrieve matching stored data rather than instructions for how to retrieve it: Cypher is declarative. Labels and key properties can appear inline in the pattern, while additional filters can be placed in `WHERE`. Both approaches can produce the same query plan and results. section 3.1.2
Listing 3.6 Cypher statement that searches and retrieves any nodes with a label Person and a name property with a value of Satish
MATCH (p:Person {name:'Satish'})
RETURN p
This query uses an inline node pattern to retrieve the Person node named Satish, then returns the node through its variable `p`. section 3.1.2
Choose the clause according to what the pattern should do:
- Use `CREATE` to store the described nodes and relationships. It creates the pattern each time and does not check whether matching data already exists. section 3.1.1
- Use `MATCH` to retrieve an existing pattern. A relationship type may be omitted when any relationship type between the described nodes is acceptable. section 3.1.2 section 3.1.6
- Use `MERGE` to match the full inline pattern first and create it only when absent. This supports repeatable imports, but matching on extra properties can produce a distinct node pattern. section 3.1.7
- Use `MATCH` followed by `DELETE` to remove a matched pattern. `DETACH DELETE` removes a node together with attached relationships. section 3.1.6
Count hashtag pairs in the same tweet
A longer pattern can express a shared context. `MATCH (h1:Tag)<-[:HAS_TAG]-()-[:HAS_TAG]->(h2:Tag)` finds two Tag nodes attached to one tweet. Counting those matches measures co-occurrence. Because each pair can appear in both variable orders, `WHERE id(h1) < id(h2)` removes duplicate pairings before the count is returned. section 7.2
Patterns also support exploratory analysis of a Twitter network: they can select users, tweets, and relationships before aggregation, subqueries, or cardinality handling. For co-occurrence projections, a conceptually undirected connection may be represented as two opposite directed relationships when working with Graph Data Science. section 4.0 section 7.2
