def count_in_and_out_degree(graph: Graph, nout, nin, nid): out_degree = 0 for edge in graph.out_edge_ids_for_node(nid): out_degree += 1 dst = graph.out_edge_dst(edge) atomic_add(nin, dst, 1) nout[nid] = out_degree
def count_weighted_in_and_out_degree(graph: Graph, nout, nin, weight_array, nid): out_degree = 0 for edge in graph.out_edge_ids(nid): weight = weight_array[edge] out_degree += weight dst = graph.out_edge_dst(edge) atomic_add(nin, dst, weight) nout[nid] = out_degree
def compute_out_deg_operator(graph: Graph, nout, nid): """Operator for computing outdegree of nodes in the Graph""" for ii in graph.out_edge_ids_for_node(nid): dst = graph.out_edge_dst(ii) atomic_add(nout, dst, 1)
def f(out, i): atomic_add(out, 0, i)