Message propagation using node frontiers generated by BFS. Parameters ---------- graph : DGLGraph The graph object. source : list, tensor of nodes Source nodes. message_func : callable The message function. reduce_func : callable The reduce fu
(
graph,
source,
message_func,
reduce_func,
reverse=False,
apply_node_func=None,
)
| 72 | |
| 73 | |
| 74 | def prop_nodes_bfs( |
| 75 | graph, |
| 76 | source, |
| 77 | message_func, |
| 78 | reduce_func, |
| 79 | reverse=False, |
| 80 | apply_node_func=None, |
| 81 | ): |
| 82 | """Message propagation using node frontiers generated by BFS. |
| 83 | |
| 84 | Parameters |
| 85 | ---------- |
| 86 | graph : DGLGraph |
| 87 | The graph object. |
| 88 | source : list, tensor of nodes |
| 89 | Source nodes. |
| 90 | message_func : callable |
| 91 | The message function. |
| 92 | reduce_func : callable |
| 93 | The reduce function. |
| 94 | reverse : bool, optional |
| 95 | If true, traverse following the in-edge direction. |
| 96 | apply_node_func : callable, optional |
| 97 | The update function. |
| 98 | |
| 99 | See Also |
| 100 | -------- |
| 101 | dgl.traversal.bfs_nodes_generator |
| 102 | """ |
| 103 | assert isinstance( |
| 104 | graph, DGLGraph |
| 105 | ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph" |
| 106 | assert ( |
| 107 | len(graph.canonical_etypes) == 1 |
| 108 | ), "prop_nodes_bfs only support homogeneous graph" |
| 109 | # TODO(murphy): Graph traversal currently is only supported on |
| 110 | # CPP graphs. Move graph to CPU as a workaround, |
| 111 | # which should be fixed in the future. |
| 112 | nodes_gen = trv.bfs_nodes_generator(graph.cpu(), source, reverse) |
| 113 | nodes_gen = [F.copy_to(frontier, graph.device) for frontier in nodes_gen] |
| 114 | prop_nodes(graph, nodes_gen, message_func, reduce_func, apply_node_func) |
| 115 | |
| 116 | |
| 117 | def prop_nodes_topo( |
nothing calls this directly
no test coverage detected