【发布时间】:2023-02-10 01:41:58
【问题描述】:
我已经开始使用 apache age 并且想知道是否有一种很酷的方法可以将 networkx graph 直接放入 apache age 数据库中?
我正在使用一种解决方法来获取与其属性相关联的边缘和节点,以使用 for 循环将它们插入到 apache 时代,是否有更好更快的方法?
【问题讨论】:
标签: python networkx graph-databases apache-age
我已经开始使用 apache age 并且想知道是否有一种很酷的方法可以将 networkx graph 直接放入 apache age 数据库中?
我正在使用一种解决方法来获取与其属性相关联的边缘和节点,以使用 for 循环将它们插入到 apache 时代,是否有更好更快的方法?
【问题讨论】:
标签: python networkx graph-databases apache-age
此功能目前正在开发中。但可以肯定的是,在未来,您会看到更多这样强大而有效的功能。
现在,您可以按照以下原始代码结构将 networkx 图放入阿帕奇时代数据库,然后将其可视化年龄观察者.
#import apache-age python driver and networkx
from apache-age import GraphDatabase
import networkx as nx
#connect to the database
driver = GraphDatabase.driver(**xyz**->argument to connect to age database**)
query = "
SELECT * FROM cypher('graph_name', $$
MATCH p = (actor {name: 'Willam Defoe'})-[:ACTED_IN*2]-(co_actor)
RETURN relationships(p)
$$) as (r agtype);"
# run the query
result = driver.run(query)
# iterate through the result
# find the nodes and edges from result
# and add them to the nx.graph
# This bit doesn't work
G = nx.Graph(result)
笔记: 代码不是可执行文件,我只提供了原始结构。
竖起大拇指!如果你觉得这个答案合适! :)
【讨论】:
【讨论】: