neonx Package

neonx Package

neonx.__init__.get_geoff(graph, edge_rel_name, encoder=None)[source]

Get the graph as Geoff string. The edges between the nodes have relationship name edge_rel_name. The code below shows a simple example:

from neonx import get_geoff

# create a graph
import networkx as nx
G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.add_edge(1, 2)
G.add_edge(2, 3)


# get the geoff string
geoff_string = get_geoff(G, 'LINKS_TO')

If the properties are not json encodable, please pass a custom JSON encoder class. See JSONEncoder.

Parameters:
  • graph – A NetworkX Graph or a DiGraph
  • edge_rel_name – Relationship name between the nodes
  • encoder (optional) – JSONEncoder object. Defaults to JSONEncoder.
Return type:

A Geoff string

neonx.__init__.write_to_neo(server_url, graph, edge_rel_name, encoder=None)[source]

Write the graph as Geoff string. The edges between the nodes have relationship name edge_rel_name. The code below shows a simple example:

from neonx import write_to_neo

# create a graph
import networkx as nx
G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.add_edge(1, 2)
G.add_edge(2, 3)


# save graph to neo4j
results = write_to_neo("http://localhost:7474/db/data/", G, 'LINKS_TO')

If the properties are not json encodable, please pass a custom JSON encoder class. See JSONEncoder.

Parameters:
  • server_url – Server URL for the Neo4j server.
  • graph – A NetworkX Graph or a DiGraph
  • edge_rel_name – Relationship name between the nodes
  • encoder (optional) – JSONEncoder object. Defaults to JSONEncoder.
Return type:

A list of Neo4j created resources.

geoff Module

neonx.geoff.get_geoff(graph, edge_rel_name, encoder=None)[source]

Get the graph as Geoff string. The edges between the nodes have relationship name edge_rel_name. The code below shows a simple example:

from neonx import get_geoff

# create a graph
import networkx as nx
G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.add_edge(1, 2)
G.add_edge(2, 3)


# get the geoff string
geoff_string = get_geoff(G, 'LINKS_TO')

If the properties are not json encodable, please pass a custom JSON encoder class. See JSONEncoder.

Parameters:
  • graph – A NetworkX Graph or a DiGraph
  • edge_rel_name – Relationship name between the nodes
  • encoder (optional) – JSONEncoder object. Defaults to JSONEncoder.
Return type:

A Geoff string

neo Module

neonx.neo.write_to_neo(server_url, graph, edge_rel_name, encoder=None)[source]

Write the graph as Geoff string. The edges between the nodes have relationship name edge_rel_name. The code below shows a simple example:

from neonx import write_to_neo

# create a graph
import networkx as nx
G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.add_edge(1, 2)
G.add_edge(2, 3)


# save graph to neo4j
results = write_to_neo("http://localhost:7474/db/data/", G, 'LINKS_TO')

If the properties are not json encodable, please pass a custom JSON encoder class. See JSONEncoder.

Parameters:
  • server_url – Server URL for the Neo4j server.
  • graph – A NetworkX Graph or a DiGraph
  • edge_rel_name – Relationship name between the nodes
  • encoder (optional) – JSONEncoder object. Defaults to JSONEncoder.
Return type:

A list of Neo4j created resources.