In [1]:
%load_ext cypher
In [2]:
%config CypherMagic
In [3]:
%cypher match (n)-[r]-() delete n, r
Out[3]:
In [4]:
%%cypher
create
// Nodes
(Neo:Crew {name:'Neo'}),
(Morpheus:Crew {name: 'Morpheus'}),
(Trinity:Crew {name: 'Trinity'}),
(Cypher:Crew:Matrix {name: 'Cypher'}),
(Smith:Matrix {name: 'Agent Smith'}),
(Architect:Matrix {name:'The Architect'}),
// Relationships
(Neo)-[:KNOWS]->(Morpheus),
(Neo)-[:LOVES]->(Trinity),
(Morpheus)-[:KNOWS]->(Trinity),
(Morpheus)-[:KNOWS]->(Cypher),
(Cypher)-[:KNOWS]->(Smith),
(Smith)-[:CODED_BY]->(Architect);
Out[4]:
In [5]:
%cypher match (n)-[r]-() return n, count(r) as degree order by degree desc
Out[5]:
In [6]:
results = %cypher match (n)-[r]-() return n.name as name, type(r) as rel, count(r) as degree order by degree desc
In [7]:
%matplotlib inline
In [8]:
results.get_dataframe()
Out[8]:
In [9]:
results.plot()
Out[9]:
In [10]:
results.bar()
Out[10]:
In [11]:
results.pie()
Out[11]:
In [11]:
for i in range(1, 5):
%cypher match (n) return n, n.name limit {i}
In [12]:
results.draw()
Out[12]:
In [13]:
results.graph
Out[13]:
In [14]:
results.dataframe
Out[14]:
In [15]:
print(results.csv())
In [16]:
from cypher import run
run("match (n)-[r]-() return n.name as name, type(r) as rel, count(r) as degree order by degree desc")
Out[16]: