MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Serializer_Graph_SetNodeLabels

Function Serializer_Graph_SetNodeLabels

src/serializers/graph_extensions.c:96–128  ·  view source on GitHub ↗

computes NodeLabelMarix out of label matrices NodeLabelMatrix[:i] = diag(LabelMatrix[i]) must be called once after all virtual keys loaded for perf

Source from the content-addressed store, hash-verified

94// NodeLabelMatrix[:i] = diag(LabelMatrix[i])
95// must be called once after all virtual keys loaded for perf
96void Serializer_Graph_SetNodeLabels
97(
98 Graph *g
99) {
100 ASSERT(g);
101
102 GrB_Vector v;
103 int node_count = Graph_RequiredMatrixDim(g);
104 int label_count = Graph_LabelTypeCount(g);
105 RG_Matrix node_labels = Graph_GetNodeLabelMatrix(g);
106 GrB_Matrix node_labels_m = RG_MATRIX_M(node_labels);
107
108#if RG_DEBUG
109 GrB_Index nvals;
110 RG_Matrix_nvals(&nvals, node_labels);
111 ASSERT(nvals == 0);
112#endif
113
114 GrB_Vector_new(&v, GrB_BOOL, node_count);
115
116 for(int i = 0; i < label_count; i++) {
117 RG_Matrix M = Graph_GetLabelMatrix(g, i);
118 GrB_Matrix m = RG_MATRIX_M(M);
119
120 GxB_Vector_diag(v, m, 0, NULL);
121
122 GxB_Row_subassign(node_labels_m, NULL, NULL, v, i, GrB_ALL, 0, NULL);
123 }
124
125 GrB_transpose(node_labels_m, NULL, NULL, node_labels_m, NULL);
126
127 GrB_Vector_free(&v);
128}
129
130// optimized version of Graph_FormConnection
131// used only when matrix doesn't contains multi edge values

Callers 6

RdbLoadGraphContext_v13Function · 0.85
RdbLoadGraphContext_v11Function · 0.85
RdbLoadGraphContext_v9Function · 0.85
RdbLoadGraphContext_v10Function · 0.85
RdbLoadGraphContext_v8Function · 0.85
RdbLoadGraphContext_v12Function · 0.85

Calls 10

Graph_RequiredMatrixDimFunction · 0.85
Graph_LabelTypeCountFunction · 0.85
Graph_GetNodeLabelMatrixFunction · 0.85
RG_Matrix_nvalsFunction · 0.85
GrB_Vector_newFunction · 0.85
Graph_GetLabelMatrixFunction · 0.85
GxB_Vector_diagFunction · 0.85
GxB_Row_subassignFunction · 0.85
GrB_transposeFunction · 0.85
GrB_Vector_freeFunction · 0.85

Tested by

no test coverage detected