apache / incubator-hugegraph-computer

HugeGraph Computer - A distributed graph processing system for hugegraph (OLAP)
https://hugegraph.apache.org/docs/quickstart/hugegraph-computer/
Apache License 2.0
42 stars 41 forks source link

[Feature] output custom write #302

Closed diaohancai closed 4 weeks ago

diaohancai commented 7 months ago

Feature Description (功能描述)

Currently, all vertices output computation results. But some scenarios do not require all vertices to output computation results. Such as Single Source Shortest Path algorithm, when targetId = "abc", then just output the computation result with the vertex id abc, no need to output results for other vertices.

dosubot[bot] commented 7 months ago

🤖

你好 @diaohancai, 很高兴再次看到你的贡献。

Based on your feature request, you want to modify the output computation results so that only specific vertices (such as targetId = "abc") are outputted, instead of all vertices. This can be achieved by modifying the writeVertex(Vertex vertex) method in the GraphComputeOutput interface or the write() method in the ComputerOutput class.

Currently, the writeVertex(Vertex vertex) method writes all vertices to the output. You can add a condition to check if the vertex id is equal to targetId before writing the vertex to the output. Here's a simple example:

public void writeVertex(Vertex vertex) {
    if (vertex.id().equals(targetId)) {
        // Write the vertex to the output
    }
}

Similarly, in the write() method of the ComputerOutput class, you can add a condition to check if the vertex id is equal to targetId before writing the vertex to the output.

public void write(Vertex vertex) {
    if (vertex.id().equals(targetId)) {
        // Write the vertex to the output
    }
}

Please note that targetId should be a variable that you can set to specify which vertices to output. Also, you need to ensure that targetId is in the correct format that can be compared with the vertex id.

This is a simple solution and may need to be adjusted based on your specific requirements and the actual implementation of the GraphComputeOutput interface and ComputerOutput class.

For more information, you can refer to the following sources:

I hope this helps! If you have any further questions or need more clarification, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.