def test_get_geoff_digraph(self): result = """(0) (1) (2 {"debug": "test\\""}) (0)-[:LINK_TO {"debug": false}]->(1) (0)-[:LINK_TO]->(2)""" graph = nx.balanced_tree(2, 1, create_using=nx.DiGraph()) graph.node[2]["debug"] = 'test"' graph[0][1]["debug"] = False self.assertEqual(get_geoff(graph, "LINK_TO"), result)
def test_get_geoff_digraph(self): result = """(0) (1) (2 {"debug": "test\\""}) (0)-[:LINK_TO {"debug": false}]->(1) (0)-[:LINK_TO]->(2)""" graph = nx.balanced_tree(2, 1, create_using=nx.DiGraph()) graph.node[2]['debug'] = 'test"' graph[0][1]['debug'] = False self.assertEqual(get_geoff(graph, 'LINK_TO'), result)
def test_get_geoff_digraph_custom(self): today = datetime.date(2012, 1, 1) result = """(0) (1) (2 {"debug": "test\\""}) (0)-[:LINK_TO {"debug": "2012-01-01"}]->(1) (0)-[:LINK_TO]->(2)""" graph = nx.balanced_tree(2, 1, create_using=nx.DiGraph()) graph.node[2]["debug"] = 'test"' graph[0][1]["debug"] = today data = get_geoff(graph, "LINK_TO", DateEncoder()) self.assertEqual(data, result)
def test_get_geoff_digraph_custom(self): today = datetime.date(2012, 1, 1) result = """(0) (1) (2 {"debug": "test\\""}) (0)-[:LINK_TO {"debug": "2012-01-01"}]->(1) (0)-[:LINK_TO]->(2)""" graph = nx.balanced_tree(2, 1, create_using=nx.DiGraph()) graph.node[2]['debug'] = 'test"' graph[0][1]['debug'] = today data = get_geoff(graph, 'LINK_TO', DateEncoder()) self.assertEqual(data, result)
def export2geoff(self): """ export the networkx representation to neo4j geoff format """ gdata = neonx.get_geoff(self, "LINKS_TO") return gdata