### Install GrandCypher using pip Source: https://github.com/aplbrain/grand-cypher/blob/master/docs/Get-Started.md This snippet shows the command-line instructions to clone the GrandCypher repository, navigate into the directory, and install the package using pip. ```shell git clone https://github.com/aplbrain/grandcypher cd grandcypher pip3 install -e . ``` -------------------------------- ### Run Cypher query on NetworkX graph with GrandCypher Source: https://github.com/aplbrain/grand-cypher/blob/master/docs/Get-Started.md Demonstrates how to initialize GrandCypher with a NetworkX graph and execute a Cypher query to retrieve all edges represented by nodes A and B. ```python from grandcypher import GrandCypher import networkx as nx my_graph = nx.read_graphml("my-fun-graph.graphml") # Get a list of all edges in the graph: results = GrandCypher(my_graph).run(""" MATCH (A)-[]->(B) RETURN A, B """) ``` -------------------------------- ### Install GrandCypher and Grandiso Source: https://github.com/aplbrain/grand-cypher/blob/master/README.md Installs the GrandCypher library and a compatible version of Grandiso for optimal performance. Grandiso is a dependency for GrandCypher. ```shell pip install grand-cypher # Note: You will want a version of grandiso>=2.2.0 for best performance! # pip install -U 'grandiso>=2.2.0' ``` -------------------------------- ### Run Cypher Queries with SQL Backend using Grand Source: https://github.com/aplbrain/grand-cypher/blob/master/README.md Shows how to use GrandCypher with a SQL backend via the Grand library. This example sets up a SQL graph, adds nodes and edges, and then runs a Cypher query to return nodes and edges based on a condition. ```python import grand from grandcypher import GrandCypher G = grand.Graph( backend=grand.backends.SQLBackend( db_url="my_persisted_graph.db", directed=True ) ) # use the networkx-style API for the Grand library: G.nx.add_node("A", foo="bar") G.nx.add_edge("A", "B") G.nx.add_edge("B", "C") G.nx.add_edge("C", "A") GrandCypher(G.nx).run(""" MATCH (A)-[]->(B)-[]->(C) MATCH (C)-[]->(A) WHERE A.foo == "bar" RETURN A, B, C """) ``` -------------------------------- ### Install GrandCypher and Grandiso Source: https://context7.com/aplbrain/grand-cypher/llms.txt Installs the GrandCypher library and the recommended Grandiso package for performance. Grandiso version 2.2.0 or higher is recommended. ```bash pip install grand-cypher # Recommended: Install grandiso>=2.2.0 for best performance pip install -U 'grandiso>=2.2.0' ``` -------------------------------- ### Run Cypher Query with Hints in Python Source: https://github.com/aplbrain/grand-cypher/blob/master/docs/Hints.md Demonstrates how to execute a Cypher query using GrandCypher in Python, providing hints to guide the query engine. Hints are passed as a list of dictionaries, mapping query variable names to specific node IDs. ```python from grandcypher import GrandCypher # Assuming 'graph' is an initialized graph object gc = GrandCypher(graph) query = "MATCH (A)-[:REL]->(B) RETURN A, B" result = gc.run(query, hints=[{"A": 1}, {"B": 2}]) ``` -------------------------------- ### Use Aggregation Functions with GrandCypher (Python) Source: https://github.com/aplbrain/grand-cypher/blob/master/docs/examples.md This example demonstrates using aggregation functions, specifically SUM, within a GrandCypher query on a NetworkX MultiDiGraph. It calculates the total amount for 'paid' relationships originating from each node. ```python from grandcypher import GrandCypher import networkx as nx host = nx.MultiDiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_edge("a", "b", __labels__={"paid"}, amount=12, date="12th June") host.add_edge("b", "a", __labels__={"paid"}, amount=6) host.add_edge("b", "a", __labels__={"paid"}, value=14) host.add_edge("a", "b", __labels__={"friends"}, years=9) host.add_edge("a", "b", __labels__={"paid"}, amount=40) qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, m.name, SUM(r.amount) """ res = GrandCypher(host).run(qry) print(res) ``` -------------------------------- ### Create and Query Multigraph with GrandCypher (Python) Source: https://github.com/aplbrain/grand-cypher/blob/master/docs/examples.md This snippet shows how to create a NetworkX MultiDiGraph, add nodes and edges with labels and properties, and then query this graph using a Cypher-like syntax with GrandCypher. It demonstrates retrieving node names and edge amounts for relationships with the 'paid' label. ```python from grandcypher import GrandCypher import networkx as nx host = nx.MultiDiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_edge("a", "b", __labels__={"paid"}, amount=12, date="12th June") host.add_edge("b", "a", __labels__={"paid"}, amount=6) host.add_edge("b", "a", __labels__={"paid"}, value=14) host.add_edge("a", "b", __labels__={"friends"}, years=9) host.add_edge("a", "b", __labels__={"paid"}, amount=40) qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, m.name, r.amount """ res = GrandCypher(host).run(qry) print(res) ``` -------------------------------- ### ID Function Usage in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Explains the use of the `ID()` function in GrandCypher queries to retrieve or filter nodes based on their unique identifiers. Examples include filtering with equality and the `IN` operator. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node(1, name="Ford Prefect") host.add_node(2, name="Arthur Dent") host.add_node(3, name="Zaphod") host.add_edge(1, 2) host.add_edge(2, 3) # Filter by ID qry = """ MATCH (A) WHERE ID(A) == 1 OR ID(A) == 2 RETURN ID(A), A.name """ result = GrandCypher(host).run(qry) # Result: {'ID(A)': [1, 2], 'A.name': ['Ford Prefect', 'Arthur Dent']} # ID with IN operator qry = """ MATCH (A) WHERE ID(A) IN [1, 3] RETURN ID(A), A.name """ result = GrandCypher(host).run(qry) # Result: {'ID(A)': [1, 3], 'A.name': ['Ford Prefect', 'Zaphod']} ``` -------------------------------- ### Assign Path to Variable in Cypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt This Python code snippet shows how to capture entire paths as variables in Cypher queries. It assigns a path of length 2 to the variable 'P' and returns it, demonstrating how to get complete traversal information including nodes and edge data. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", name="x") host.add_node("y", name="y") host.add_node("z", name="z") host.add_edge("x", "y", foo="bar") host.add_edge("y", "z") # Assign path to variable P qry = """ MATCH P = ()-[r*2]->() RETURN P LIMIT 1 """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### Filter Graph Data with WHERE Clause in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Illustrates filtering graph query results using the WHERE clause in GrandCypher. It supports comparison operators, boolean logic (AND/OR), string operations (CONTAINS, STARTS WITH, ENDS WITH), list membership (IN), and NULL checking. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", name="Ford Prefect", age=200) host.add_node("y", name="Arthur Dent", age=30) host.add_node("z", name="Zaphod", age=250) host.add_edge("x", "y", years_known=10) host.add_edge("y", "z", years_known=5) # Simple comparison qry = """ MATCH (A)-[r]->(B) WHERE A.age > 100 RETURN A.name, B.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Ford Prefect'], 'B.name': ['Arthur Dent']} # Boolean logic with AND/OR qry = """ MATCH (A) WHERE A.age > 50 AND A.name CONTAINS "Zaphod" RETURN A.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Zaphod']} # String operations qry = """ MATCH (A) WHERE A.name STARTS WITH "Ford" OR A.name ENDS WITH "Dent" RETURN A.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Ford Prefect', 'Arthur Dent']} # IN operator for list membership qry = """ MATCH (A) WHERE A.age IN [30, 200] RETURN A.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Ford Prefect', 'Arthur Dent']} # NULL checking qry = """ MATCH (A) WHERE A.missing_attr IS NULL RETURN A.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Ford Prefect', 'Arthur Dent', 'Zaphod']} # NOT operator qry = """ MATCH (A) WHERE NOT A.name CONTAINS "Ford" RETURN A.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Arthur Dent', 'Zaphod']} ``` -------------------------------- ### Filter Nodes and Edges by Labels in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Shows how to use node and edge labels for filtering in GrandCypher queries. Labels are stored in the `__labels__` attribute as a set. This example demonstrates filtering by single node labels, single edge labels, and multiple node labels using the OR operator. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("a", __labels__={"Person", "Employee"}, name="Alice") host.add_node("b", __labels__={"Person", "Manager"}, name="Bob") host.add_node("c", __labels__={"Company"}, name="Acme Inc") host.add_edge("a", "c", __labels__={"WORKS_FOR"}, since=2020) host.add_edge("b", "c", __labels__={"MANAGES"}, since=2018) host.add_edge("a", "b", __labels__={"REPORTS_TO"}, since=2021) # Filter by node label qry = """ MATCH (p:Person)-[]->(c:Company) RETURN p.name, c.name """ result = GrandCypher(host).run(qry) # Result: {'p.name': ['Alice', 'Bob'], 'c.name': ['Acme Inc', 'Acme Inc']} # Filter by edge label qry = """ MATCH (p)-[r:WORKS_FOR]->(c) RETURN p.name, c.name, r.since """ result = GrandCypher(host).run(qry) # Result: {'p.name': ['Alice'], 'c.name': ['Acme Inc'], 'r.since': [2020]} # Multiple labels with OR operator qry = """ MATCH (n:Employee|Manager)-[r]->(c:Company) RETURN n.name """ result = GrandCypher(host).run(qry) # Result: {'n.name': ['Alice', 'Bob']} ``` -------------------------------- ### Aliasing with AS in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Demonstrates how to use the 'AS' keyword in GrandCypher queries to rename returned columns for cleaner output. This is useful for both simple column renaming and for aliasing aggregated values. ```python from grandcypher import GrandCypher import networkx as nx host = nx.MultiDiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_edge("a", "b", __labels__={"paid"}, value=14) host.add_edge("a", "b", __labels__={"paid"}, value=9) # Alias for aggregation qry = """ MATCH (n)-[r]->(m) RETURN n.name, AVG(r.value) AS average, m.name ORDER BY average ASC """ result = GrandCypher(host).run(qry) # Result: {'n.name': ['Alice'], 'm.name': ['Bob'], 'average': [11.5]} # Alias for node IDs qry = """ MATCH (A)-[r*1]->(B) RETURN ID(A) AS source, ID(B) AS target """ result = GrandCypher(host).run(qry) # Result: {'source': ['a'], 'target': ['b']} ``` -------------------------------- ### Query Hints for Performance in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Demonstrates how to use query hints in GrandCypher to improve performance by specifying known node mappings. This allows the query planner to prioritize certain nodes, especially in large graphs. ```python from grandcypher import GrandCypher import networkx as nx # Create a larger graph host = nx.DiGraph() for i in range(1000): host.add_node(i, value=i) for i in range(999): host.add_edge(i, i+1) # Query with hints for better performance qry = """ MATCH (A)-[]->(B) RETURN ID(A), ID(B) LIMIT 10 """ gc = GrandCypher(host) # Provide hints mapping query variables to known node IDs result = gc.run(qry, hints=[{"A": 0}, {"A": 1}]) # Result will prioritize matches starting from nodes 0 and 1 ``` -------------------------------- ### Run Cypher Queries with NetworkX Graphs Source: https://github.com/aplbrain/grand-cypher/blob/master/README.md Demonstrates how to use GrandCypher to run Cypher queries on a NetworkX graph. It initializes GrandCypher with a NetworkX graph and executes a Cypher query to return clubs based on a 'Mr. Hi' condition. ```python from grandcypher import GrandCypher import networkx as nx GrandCypher(nx.karate_club_graph()).run(""" MATCH (A)-[]->(B) MATCH (B)-[]->(C) WHERE A.club == "Mr. Hi" RETURN A.club, B.club """) ``` -------------------------------- ### Execute Basic Cypher Queries with GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Demonstrates how to execute basic Cypher queries using the GrandCypher class with a NetworkX DiGraph. It shows how to return entire nodes and specific attributes. ```python from grandcypher import GrandCypher import networkx as nx # Create a simple directed graph host = nx.DiGraph() host.add_node("x", name="Alice", age=30) host.add_node("y", name="Bob", age=25) host.add_node("z", name="Carol", age=35) host.add_edge("x", "y", relationship="friend") host.add_edge("y", "z", relationship="colleague") # Execute a basic query qry = """ MATCH (A)-[]->(B) RETURN A, B """ result = GrandCypher(host).run(qry) # Result: {'A': [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}], # 'B': [{'name': 'Bob', 'age': 25}, {'name': 'Carol', 'age': 35}]} # Return specific attributes qry = """ MATCH (A)-[]->(B) RETURN A.name, B.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['Alice', 'Bob'], 'B.name': ['Bob', 'Carol']} ``` -------------------------------- ### ORDER BY, LIMIT, SKIP, and DISTINCT in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Explains how to control result ordering, pagination, and uniqueness using standard Cypher clauses like `ORDER BY`, `LIMIT`, `SKIP`, and `DISTINCT` in GrandCypher. These clauses are essential for managing and refining query outputs. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_node("c", name="Carol", age=20) host.add_node("d", name="Alice", age=35) # Duplicate name # ORDER BY ascending qry = """ MATCH (n) RETURN n.name ORDER BY n.age ASC """ result = GrandCypher(host).run(qry) # ORDER BY descending with LIMIT qry = """ MATCH (n) RETURN n.name ORDER BY n.age DESC LIMIT 2 """ result = GrandCypher(host).run(qry) # SKIP for pagination qry = """ MATCH (n) RETURN n.name ORDER BY n.age ASC SKIP 1 LIMIT 2 """ result = GrandCypher(host).run(qry) # DISTINCT to remove duplicates qry = """ MATCH (n) RETURN DISTINCT n.name """ result = GrandCypher(host).run(qry) # ORDER BY with DISTINCT qry = """ MATCH (n) RETURN DISTINCT n.name, n.age ORDER BY n.age DESC """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### Node Property Matching with Dict Syntax in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Illustrates how to match nodes directly by their property values using inline dictionary syntax within GrandCypher queries. This method allows for concise filtering based on node attributes. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", type="foo", status="active") host.add_node("y", type="bar", status="inactive") host.add_node("z", type="foo", status="inactive") host.add_edge("x", "y") host.add_edge("y", "z") # Match by property qry = """ MATCH (A {type: "foo"})-[]->(B) RETURN A, B """ result = GrandCypher(host).run(qry) # Result: {'A': [{'type': 'foo', 'status': 'active'}], # 'B': [{'type': 'bar', 'status': 'inactive'}]} # Combine with labels qry = """ MATCH (A:Node {status: "active"})-[]->(B) RETURN A """ ``` -------------------------------- ### Subqueries with EXISTS in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Explains how to use `EXISTS` subqueries in GrandCypher to filter results based on the existence of specific patterns. It covers basic `EXISTS`, `EXISTS` with additional conditions, and negated `EXISTS` (NOT EXISTS). ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", age=15) host.add_node("y", age=25) host.add_node("z", age=35) host.add_node("zz", age=45) host.add_edge("x", "z") host.add_edge("x", "zz") host.add_edge("y", "z") # Basic EXISTS subquery qry = """ MATCH (A) WHERE EXISTS { MATCH (A) --> (B) WHERE B.age > 30 } RETURN ID(A) """ result = GrandCypher(host).run(qry) # Result: {'ID(A)': ['x', 'y']} # EXISTS with additional conditions qry = """ MATCH (A) WHERE A.age < 20 AND EXISTS { MATCH (A) --> (B) WHERE B.age > 30 } RETURN ID(A) """ result = GrandCypher(host).run(qry) # Result: {'ID(A)': ['x']} # Negated EXISTS (NOT EXISTS) host2 = nx.DiGraph() host2.add_node("x") host2.add_node("y") host2.add_node("z") host2.add_edge("x", "y", __labels__={"XY"}, name="XY") host2.add_edge("x", "z", __labels__={"XZ"}, name="XZ") qry = """ MATCH (A) --> (B) WHERE NOT EXISTS { MATCH (A) -[:XY]-> (B) } RETURN ID(A), ID(B) """ result = GrandCypher(host2).run(qry) # Result: {'ID(A)': ['x'], 'ID(B)': ['z']} ``` -------------------------------- ### Aggregation Functions in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Demonstrates the use of aggregation functions like `COUNT`, `SUM`, `AVG`, `MIN`, and `MAX` to compute statistics over matched results in GrandCypher. These functions allow for summarizing data from graph relationships. ```python from grandcypher import GrandCypher import networkx as nx host = nx.MultiDiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_node("c", name="Carol", age=35) host.add_edge("a", "b", __labels__={"paid"}, amount=40) host.add_edge("a", "b", __labels__={"paid"}, amount=12) host.add_edge("b", "c", __labels__={"paid"}, amount=25) # SUM aggregation qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, m.name, SUM(r.amount) """ result = GrandCypher(host).run(qry) # COUNT aggregation qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, COUNT(r.amount) """ result = GrandCypher(host).run(qry) # AVG, MIN, MAX qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, AVG(r.amount), MIN(r.amount), MAX(r.amount) """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### BibTeX Citation for GrandCypher Source: https://github.com/aplbrain/grand-cypher/blob/master/README.md Provides the BibTeX entry for citing the GrandCypher tool in academic research, referencing the 'DotMotif' publication. ```bibtex # https://doi.org/10.1038/s41598-021-91025-5 @article{Matelsky_Motifs_2021, title={{DotMotif: an open-source tool for connectome subgraph isomorphism search and graph queries}}, volume={11}, ISSN={2045-2322}, url={http://dx.doi.org/10.1038/s41598-021-91025-5}, DOI={10.1038/s41598-021-91025-5}, number={1}, journal={Scientific Reports}, publisher={Springer Science and Business Media LLC}, author={Matelsky, Jordan K. and Reilly, Elizabeth P. and Johnson, Erik C. and Stiso, Jennifer and Bassett, Danielle S. and Wester, Brock A. and Gray-Roncal, William}, year={2021}, month={Jun} } ``` -------------------------------- ### Variable-Length Relationships (Edge Hops) in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Illustrates matching paths with variable-length relationships using the `*min..max` syntax. This allows traversal of multiple edges, specifying exact hop counts, zero hops, or a range of hops. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", foo=12) host.add_node("y", foo=13) host.add_node("z", foo=16) host.add_edge("x", "y", bar="1") host.add_edge("y", "z", bar="2") host.add_edge("z", "x", bar="3") # Exact hop count (*2 means exactly 2 hops) qry = """ MATCH (A)-[r*2]->(B) RETURN ID(A), ID(B), r """ result = GrandCypher(host).run(qry) # Zero hops (same node) qry = """ MATCH (A)-[r*0]->(B) RETURN ID(A), ID(B) """ result = GrandCypher(host).run(qry) # Range of hops (*0..2 means 0 to 2 hops) qry = """ MATCH (A)-[r*0..2]->(B) RETURN ID(A), ID(B) """ result = GrandCypher(host).run(qry) # Single hop with label filter qry = """ MATCH (A)-[:Edge*1..2]->(B) RETURN ID(A), ID(B) """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### MultiDiGraph Support and Edge Attribute Filtering in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Shows how GrandCypher supports NetworkX `MultiDiGraph` for graphs with multiple edges between nodes. It demonstrates querying specific edge types and filtering edges based on their attributes using a WHERE clause. ```python from grandcypher import GrandCypher import networkx as nx host = nx.MultiDiGraph() host.add_node("a", name="Alice", age=25) host.add_node("b", name="Bob", age=30) host.add_edge("a", "b", __labels__={"paid"}, amount=12, date="12th June") host.add_edge("a", "b", __labels__={"paid"}, amount=40) host.add_edge("a", "b", __labels__={"friends"}, years=9) host.add_edge("b", "a", __labels__={"paid"}, amount=6) # Query specific edge type qry = """ MATCH (n)-[r:paid]->(m) RETURN n.name, m.name, r.amount """ result = GrandCypher(host).run(qry) # WHERE clause on edge attributes qry = """ MATCH (n)-[r:paid]->(m) WHERE r.amount > 20 RETURN n.name, m.name, r.amount """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### Bidirectional and Chained Edges in Python Source: https://context7.com/aplbrain/grand-cypher/llms.txt Covers GrandCypher's support for various edge traversal patterns, including undirected edges (`-[]-`), backward edges (`<-[]-`), and chained multi-hop patterns (`-[]->(B)-[]->(C)`). ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() host.add_node("x", name="x") host.add_node("y", name="y") host.add_node("z", name="z") host.add_edge("x", "y", foo="bar") host.add_edge("y", "x") # Reverse edge host.add_edge("y", "z") # Undirected edge match (matches either direction) qry = """ MATCH (A) -[]- (B) RETURN A.name, B.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['x', 'y'], 'B.name': ['y', 'x']} # Backward edge match qry = """ MATCH (A) <-[]- (B) RETURN A.name, B.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['y', 'x', 'z'], 'B.name': ['x', 'y', 'y']} # Chained edges qry = """ MATCH (A)-[]->(B)-[]->(C) RETURN A.name, B.name, C.name """ result = GrandCypher(host).run(qry) # Result: {'A.name': ['x'], 'B.name': ['y'], 'C.name': ['z']} ``` -------------------------------- ### Match Anonymous Nodes in Cypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt This snippet demonstrates how to match anonymous nodes in a graph using Cypher. It finds nodes connected by specific relationships and returns a property of the matched node 'B'. ```python qry = """ MATCH ()-[]->(B)<-[]-() RETURN B.name """ result = GrandCypher(host).run(qry) ``` -------------------------------- ### Edge Labels with OR Operator in GrandCypher Source: https://context7.com/aplbrain/grand-cypher/llms.txt Demonstrates how to match nodes connected by edges with specific labels using the OR operator. This query returns the names of nodes connected by 'WORKS_FOR' or 'MANAGES' relationships. ```python from grandcypher import GrandCypher import networkx as nx host = nx.DiGraph() # Assuming nodes and edges are added to host qry = """ MATCH (a)-[r:WORKS_FOR|MANAGES]->(b) RETURN a.name, b.name """ result = GrandCypher(host).run(qry) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.