【问题标题】:create apache age graph from networkx graph从 networkx 图创建 apache 年龄图
【发布时间】:2023-02-10 01:41:58
【问题描述】:

我已经开始使用 apache age 并且想知道是否有一种很酷的方法可以将 networkx graph 直接放入 apache age 数据库中?

我正在使用一种解决方法来获取与其属性相关联的边缘和节点,以使用 for 循环将它们插入到 apache 时代,是否有更好更快的方法?

【问题讨论】:

    标签: python networkx graph-databases apache-age


    【解决方案1】:

    此功能目前正在开发中。但可以肯定的是,在未来,您会看到更多这样强大而有效的功能。

    现在,您可以按照以下原始代码结构将 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)
    

    笔记: 代码不是可执行文件,我只提供了原始结构。

    竖起大拇指!如果你觉得这个答案合适! :)

    【讨论】:

      【解决方案2】:

      该功能当前不可用。目前,其他发展具有更高的优先级。

      话虽如此,您可以在 Github 存储库中请求该功能:

      https://github.com/apache/age

      如果幸运的话,它可能会被接受。

      【讨论】:

        猜你喜欢
        • 2014-07-22
        • 1970-01-01
        • 2018-07-13
        • 1970-01-01
        • 1970-01-01
        • 2023-01-29
        • 1970-01-01
        • 1970-01-01
        • 2021-01-09
        相关资源
        最近更新 更多