コード例 #1
0
ファイル: graph_extractor.py プロジェクト: rcbull/brasil.io
def _extract_network(query, path_key="p"):
    graph = nx.DiGraph()
    output = get_graph_db_connection().run(query)
    while output.forward():
        path = output.current()[path_key]
        nodes = path.nodes()
        rels = path.relationships()

        for node in nodes:
            labels = list(node.labels())
            graph.add_node(node.__name__, tipo=labels[0], labels=labels, **node.properties)

        for rel in rels:
            graph.add_edge(
                rel.start_node().__name__, rel.end_node().__name__, tipo_relacao=rel.type(), **rel.properties
            )

    return graph
コード例 #2
0
 def __init__(self, *args, **kwargs):
     super(BaseCommand, self).__init__(*args, **kwargs)
     self.graph_db = get_graph_db_connection()
コード例 #3
0
def selector():
    return NodeSelector(get_graph_db_connection())
コード例 #4
0
 def __init__(self, *args, **kwargs):
     super(BaseCommand, self).__init__(*args, **kwargs)
     self.open_transaction = None
     self.batch_size = 1000
     self.graph_db = get_graph_db_connection()
     self.company_names = {}