Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

bruth/graphlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph Library

Build Status Coverage Status

Graph API, serializer, and loader that conforms to the JSON Graph Spec.

Install

pip install graphlib

Usage

Create

The object API makes it simple to create nodes and relationships between them.

from graphlib import Node

city = Node({'location': 'Philadelphia'})
jane = Node({'name': 'Jane'})
john = Node({'name': 'John'})
bob = Node({'name': 'Bob'})

city.relate([jane, john, bob], 'LIVES_IN')
jane.relate(john, 'MARRIED_TO')
john.relate(bob, 'FRIENDS_WITH')

Serialize

Serializes the object reprsentations into dicts and lists which can be encoded as JSON or loaded into a graph database.

from graphlib import serialize

data = serialize(city)

Load

Takes the serialized data and loads it into a database. This example loads it into Neo4j.

from graphlib import neo4j

neo4j.load(data)

CLI

The Neo4j module can be used directly via the command line:

python -m 'graphlib.neo4j' [path/to/file.json] [--load] [uri]

By default, stdin will be read which should be valid JSON that will be parsed and converted into Cypher statements and printed to stdout. If a path supplied, the file will be read instead of stdin. If the --load flag is present, the statements will be executed on the Neo4j server at the default URI unless a custom URI is provided.

About

Graph API and serializer for the JSON Graph Spec

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors