Pregel Programming API
When implementing the init and compute methods in UserPregelAlgorithm, users mainly rely on the PregelContext object, which provides the following APIs:
Method and Attribute |
Description |
Remarks |
---|---|---|
ext_id(nid)->int |
Obtains the user-defined external ID of the current vertex. Only IDs that can be converted to the int type are supported. |
Basic operations on graph data (values and topologies) |
value(nid)->int/float/bool |
Obtains the value of the current vertex. |
|
set_value(nid, new_value)->None |
Sets the value of the current vertex. |
|
out_edges(nid) -> List[int] |
Obtains the list of outgoing edges of the current vertex. |
|
edge_dst(eid)->int |
Obtains the target vertex of the current edge. |
|
num_nodes |
Obtains the number of vertices in a full graph. |
|
num_edges |
Obtains the total number of edges in a full image. |
|
send(dst_nid, msg)->None |
Sends messages to the target vertex. |
Data exchange operation between vertices |
halt(nid) ->None |
Sets the current vertex to the halt state. |
When all vertices in the graph are in the halt state and there are no messages, or when supersteps reach the maximum number of iterations, the algorithm terminates. |
superstep -> int |
Obtain the current number of supersteps. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot