GeaFlow (TuGraph-Analytics)
GeaFlow是蚂蚁集团开源的分布式实时图计算引擎,支持流式图计算,广泛应用于金融风控、社交网络等场景。它提供SQL+GQL融合分析语言,支持K8S部署,并内置PageRank等图算法。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
GeaFlow是蚂蚁集团开源的分布式实时图计算引擎,支持流式图计算,广泛应用于金融风控、社交网络等场景。它提供SQL+GQL融合分析语言,支持K8S部署,并内置PageRank等图算法。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
sqlINSERT INTO tbl_resultCALL page_rank() YIELD (vid, prValue)RETURN vid, prValue;我们通过CALL语句调用具体的算法,通过YIELD定义算法的返回字段,比如page_rank算法返回点id和page rank值两个字段,则可以通过YIELD(vid, prValue)来表示。DSL里面实现一个图算法需要实现AlgorithmUserFunction接口,其定义如下:java/** * Interface for the User Defined Graph Algorithm. * @param <K> The id type for vertex. * @param <M> The message type for message send between vertices. */public interface AlgorithmUserFunction<K, M> extends Serializable { /** * Init method for the function * @param context The runtime context. * @param params The parameters for the function. */ void init(AlgorithmRuntimeContext<K, M> context, Object[] params); /** * Processing method for each vertex and the messages it received. */ void process(RowVertex vertex, Iterator<M> messages); /** * Returns the output type for the function. */ StructType getOutputType();}* init算法的初始化接口,主要完成算法的一些初始化操作. PageRank的init方法实现如下:java@Override public void init(AlgorithmRuntimeContext context, Object[] parameters) { this.context = context; if (parameters.length > 3) { throw new IllegalArgumentException( "Only support zero or more arguments, false arguments " + "usage: func([alpha, [convergence, [max_iteration]]])"); } // 修正系数,即前面介绍的参数d. if (parameters.length > 0) { alpha = Double.parseDouble(String.valueOf(parameters[0])); } // PR值更新阀值,当点的pr差值小于该值时,不再更新pr值. if (parameters.length > 1) { convergence = Double.parseDouble(String.valueOf(parameters[1])); } // 迭代次数 if (parameters.length > 2) { iteration = Integer.parseInt(String.valueOf(parameters[2])); } }* process算法的主要处理逻辑,入参为当前Active点和要处理的消息,PageRank主要实现如下:java @Override public void process(RowVertex vertex, Iterator messages) { .... if (context.getCurrentIterationId() == 1L) { // 首轮迭代设置pr初始值,并发送给出边,同时更新当前点的pr值。 double initValue = 1.0; sendMessageToNeighbors(outEdges, initValue / outEdges.size()); ... context.updateVertexValue(ObjectRow.create(initValue)); } else if (context.getCurrentIterationId() < iteration) { double sum = 0.0; while (messages.hasNext()) { double input = (double) messages.next(); input = input > 0 ? input : 0.0; sum += input; } // 计算当前迭代的pr值 double pr = (1 - alpha) + (sum * alpha); double currentPr = (double) vertex.getValue().getField(0, DoubleType.INSTANCE); if (Math.abs(currentPr - pr) > convergence) { // pr值发送给出边目标点. sendMessageToNeighbors(outEdges, pr / outEdges.size()); } context.updateVertexValue(ObjectRow.create(pr)); } else { // 到达最大迭代次数,结束本轮迭代,take最终计算结果. double currentPr = (double) vertex.getValue().getField(0, DoubleType.INSTANCE); context.take(ObjectRow.create(vertex.getId(), currentPr)); return; } }* getOutputType定义算法返回类型,PageRank实现如下:java @Override public StructType getOutputType() { return new StructType( // id new TableField("id", LongType.INSTANCE, false), // pr值 new TableField("pr", DoubleType.INSTANCE, false) ); }## 算法注册算法实现通过注解来定义算法名称,如下所示:java@Description(name = "page_rank", description = "built-in udga for PageRank")public class PageRank implements AlgorithmUserFunction {}算法和UDF一样,需要注册或者创建后才能使用. DSL内置算法或者UDF在BuildInSqlFunctionTable�中进行注册.对于非内置算法,可以通过create function语句来创建.javaCreate funciton page_rank as 'com.antgroup.geaflow.dsl.udf.graph.PageRank';# 总结本文主要介绍实时图计算引擎GeaFlow的基本架构,然后介绍了图算法PageRank的基本原理以及在GeaFlow中的实现细节和使用方式.GeaFlow(品牌名TuGraph-Analytics) 已正式开源,欢迎大家关注!!!Welcome to give us a Star!GitHub👉https://github.com/TuGraph-family/tugraph-analytics更多精彩内容,关注我们的博客 https://geaflow.github.io/A code-free online store builder to turn views into revenue. Sell digital products, subscriptions, and merch, without fees or hassle.
Convert videos into awesome blog posts.
Fast Image AI instantly transforms your photos into stunning styles like Ghibli, Sketch, and Pixar. Effortlessly control image elements and create amazing effects with just one click.
AI-powered tool that transforms casual photos into professional LinkedIn headshots instantly. No photographer needed—just upload and download.
Crevas unifies Veo 3, Sora 2, Nano Banana and more into one intuitive canvas — so filmmakers can script, prompt, and generate cinematic stories without switching tools or losing consistency.
AI Foto Edit - Text to Image & Image Edit