联 系 我 们
售前咨询
售后咨询
微信关注:星环科技服务号
更多联系方式 >
6.5.4 图算法结果扩展
更新时间:2/14/2025, 6:56:55 AM
图算法结果写回图 (3.0版本)
match (a)-[f]->(b) with <GRAPH_ALGO> as unapply(vertex, result) set findNodeWithId(vertex).property_name = result;
复制

示例:

match (a)-[f]->(b) with graph_pagerank(id(a), id(b)) as unapply(v, r) set findNodeWithId(v).rank = r;
复制

通过执行该语句,将 PageRank 算法,通过用 findNodeWithId() 函数找到对应节点,并将节点的 rank 值更新为 r

  • findNodeWithId()方法意义是根据内部id找到节点,所以要求参数vertex来源是内部id值,目前供此场景下专用。

  • 目前property_name只能是创图时schema里指定的列名,不支持动态生成新的列名。如果预期要根据图算法写回图中,请提前在schema里指定要写入的列。

图算法结果写回图 (4.0版本及以上)
create query temporary graph view GRAPH_VIEW_NAME as (v) [e] with GRAPH_ALGO(@GRAPH_VIEW_NAME, VIEW_STORE_PATH, CONFIG_MAP, PROPS) as unapply(vertex, result) bulk set findNodeWithId(vertex).property_name = result;
复制

示例:

create temporary graph view sample_1 as (v) [e] with graph_pagerank(@sample_1, "/tmp/view_1", '{factor: 0.85, rounds: 5}') as unapply(v, r) bulk set findNodeWithId(v).rank = r;
复制

通过执行此语句,将 PageRank 算法,通过用 findNodeWithId() 函数找到对应节点,并将节点的 rank 值更新为 r

目前property_name只能是创图时schema里指定的列名,不支持动态生成新的列名。如果预期要根据图算法写回图中,请提前在schema里指定要写入的列。

图算法结果导出至关系型表

图算法结果支持导出至Quark的文本型数据表:

  1. 表结构将由导出内容决定;

  2. 模型列名为_a_c0,_a_c1等,需要通过alias来自定义列名;

示例 - 导出PageRank算法结果至test_db.page_rank_result

create query temporary graph view algo_test_view_1 as (a) [b] with graph_pagerank(@algo_test_view_1, "/tmp/algo_test_view_1", '{factor: 0.85, rounds: 10}') as unapply(vertex, rank) store tostring(uid(vertex)) as uid, todouble(rank) as rank_value into txt table test_db.page_rank_result;
复制