Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
 def export2geoff(self):
     """
     export the networkx representation to neo4j geoff format
     """
     gdata = neonx.get_geoff(self, "LINKS_TO")
     return gdata