Connect cypher queries

Load the extension


In [1]:
%%capture
%reload_ext cypher

Define URL for connection


In [2]:
from libs.graph import connect_icypher


INFO:libs.graph.graph:Graph is connected

Queries to the GraphDB


In [3]:
%cypher match (n) return n limit 1


1 rows affected.
Out[3]:
n
{'name': 'cinecaDMPZone'}

In [4]:
%%cypher
match (n) return n limit 2


2 rows affected.
Out[4]:
n
{'name': 'cinecaDMPZone'}
{'path': '/cinecaDMPZone/home/pdonorio/data/abc_Asek8HXxB3zalvspNx0Ng1JbJsRSciIx.txt', 'location': 'irods://130.186.13.14:1247/cinecaDMPZone/home/pdonorio/data/abc_Asek8HXxB3zalvspNx0Ng1JbJsRSciIx.txt', 'filename': 'abc_Asek8HXxB3zalvspNx0Ng1JbJsRSciIx.txt'}

In [21]:
results = %cypher MATCH (a)-[]-(b) RETURN a, b limit 3


3 rows affected.

In [22]:
# Pandas
results.get_dataframe()


Out[22]:
a b
0 {'path': '/cinecaDMPZone/home/pdonorio/mydata/... {'name': 'cinecaDMPZone'}
1 {'path': '/cinecaDMPZone/home/pdonorio/mydata/... {'name': 'cinecaDMPZone'}
2 {'path': '/cinecaDMPZone/home/pdonorio/mydata/... {'name': 'cinecaDMPZone'}

In [23]:
# Networkx
results.get_graph()


Out[23]:
<networkx.classes.multidigraph.MultiDiGraph at 0x7f22d2e649b0>

In [24]:
%matplotlib inline
#results.plot()

Problem with cypher

A python3 problem


In [25]:
results.draw()


Out[25]:
(<networkx.classes.multidigraph.MultiDiGraph at 0x7f22d478e2e8>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7f22d2e59438>,
 <matplotlib.collections.PathCollection at 0x7f22d2dd02b0>)

In [ ]: