MCPcopy
hub / github.com/dmlc/dgl / prop_edges_dfs

Function prop_edges_dfs

python/dgl/propagate.py:153–206  ·  view source on GitHub ↗

Message propagation using edge frontiers generated by labeled DFS. Parameters ---------- graph : DGLGraph The graph object. source : list, tensor of nodes Source nodes. message_func : callable, optional The message function. reduce_func : callable, op

(
    graph,
    source,
    message_func,
    reduce_func,
    reverse=False,
    has_reverse_edge=False,
    has_nontree_edge=False,
    apply_node_func=None,
)

Source from the content-addressed store, hash-verified

151
152
153def prop_edges_dfs(
154 graph,
155 source,
156 message_func,
157 reduce_func,
158 reverse=False,
159 has_reverse_edge=False,
160 has_nontree_edge=False,
161 apply_node_func=None,
162):
163 """Message propagation using edge frontiers generated by labeled DFS.
164
165 Parameters
166 ----------
167 graph : DGLGraph
168 The graph object.
169 source : list, tensor of nodes
170 Source nodes.
171 message_func : callable, optional
172 The message function.
173 reduce_func : callable, optional
174 The reduce function.
175 reverse : bool, optional
176 If true, traverse following the in-edge direction.
177 has_reverse_edge : bool, optional
178 If true, REVERSE edges are included.
179 has_nontree_edge : bool, optional
180 If true, NONTREE edges are included.
181 apply_node_func : callable, optional
182 The update function.
183
184 See Also
185 --------
186 dgl.traversal.dfs_labeled_edges_generator
187 """
188 assert isinstance(
189 graph, DGLGraph
190 ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
191 assert (
192 len(graph.canonical_etypes) == 1
193 ), "prop_edges_dfs only support homogeneous graph"
194 # TODO(murphy): Graph traversal currently is only supported on
195 # CPP graphs. Move graph to CPU as a workaround,
196 # which should be fixed in the future.
197 edges_gen = trv.dfs_labeled_edges_generator(
198 graph.cpu(),
199 source,
200 reverse,
201 has_reverse_edge,
202 has_nontree_edge,
203 return_labels=False,
204 )
205 edges_gen = [F.copy_to(frontier, graph.device) for frontier in edges_gen]
206 prop_edges(graph, edges_gen, message_func, reduce_func, apply_node_func)

Callers

nothing calls this directly

Calls 3

prop_edgesFunction · 0.85
cpuMethod · 0.45
copy_toMethod · 0.45

Tested by

no test coverage detected