subgraph Module

The py2neo.subgraph module allows abstract subgraph data to be merged into a database in a single step. For example:

abstract = {
    "People": {
        "__uniquekey__": "email",
        "__nodes__": {
            "alice": {"name": "Alice", "email": "alice@example.com"},
            "bob":   {"name": "Bob", "email": "bob@example.com"}
        },
        "__rels__": [
            ["alice", "KNOWS", "bob"]
        ]
    }
}
nodes = subgraph.merge(abstract, self.graph_db)
alice, bob = nodes["People"]["alice"], nodes["People"]["bob"]
class py2neo.subgraph.Subgraph(abstract)[source]

Bases: object

class Category(name, data)[source]

Bases: object

unique_nodes[source]

Return all nodes which contain the key designated as unique.

Subgraph.has_rels[source]
Subgraph.merge(graph_db)[source]
Subgraph.nodes[source]
py2neo.subgraph.merge(abstract, graph_db)[source]

Merge an abstract subgraph into a graph database.

Parameters:
  • abstract – abstract subgraph data
  • graph_db – the graph into which to merge the data
Returns:

collection of subgraph nodes

Previous topic

cypher Module

Next topic

geoff Module

This Page