更新时间:2022-06-30 GMT+08:00

批量添加边

您可以使用GES提供的接口批量添加边。示例代码如下:
public static void addBatchEdges(GraphClient graphClient) throws ApiException 
{
    // 构造边信息
    Edge edge = new Edge();
    edge.setSource("46");
    edge.setTarget("38");
    edge.setLabel("rate");
    Map<String, List<Object>> properties = new HashMap<>();
    properties.put("Rating", Arrays.asList("5"));
    properties.put("Datetime", Arrays.asList("2018-01-0120:30:05"));
    edge.setProperties(properties);

    // 组成边列表
    List<Edge> edges = new ArrayList<>();
    edges.add(edge);

    // 默认选项为允许重复边
    ParallelEdgeOption parallelEdgeOption = new ParallelEdgeOption();

    // 构造添加批量边请求
    AddBatchEdgeReq addBatchEdgeReq = new AddBatchEdgeReq();
    addBatchEdgeReq.setEdges(edges);
    addBatchEdgeReq.setParallelEdge(parallelEdgeOption);

    // 执行添加批量边请求
    Map<String, Object> result = graphClient.addBatchEdge(addBatchEdgeReq);    
}