delete a node remove the node from the relevant indexes add node deletion operation to undo-log return 1 on success, 0 otherwise
| 155 | // add node deletion operation to undo-log |
| 156 | // return 1 on success, 0 otherwise |
| 157 | void DeleteNodes |
| 158 | ( |
| 159 | GraphContext *gc, |
| 160 | Node *nodes, |
| 161 | uint n, |
| 162 | bool log |
| 163 | ) { |
| 164 | ASSERT(gc != NULL); |
| 165 | ASSERT(nodes != NULL); |
| 166 | |
| 167 | bool has_indices = GraphContext_HasIndices(gc); |
| 168 | |
| 169 | UndoLog undo_log = (log) ? QueryCtx_GetUndoLog() : NULL; |
| 170 | EffectsBuffer *eb = (log) ? QueryCtx_GetEffectsBuffer() : NULL; |
| 171 | for(uint i = 0; i < n; i++) { |
| 172 | Node *n = nodes + i; |
| 173 | |
| 174 | if(log) { |
| 175 | // add node deletion operation to undo log |
| 176 | UndoLog_DeleteNode(undo_log, n); |
| 177 | EffectsBuffer_AddDeleteNodeEffect(eb, n); |
| 178 | } |
| 179 | |
| 180 | if(has_indices) { |
| 181 | _DeleteNodeFromIndices(gc, n); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | Graph_DeleteNodes(gc->g, nodes, n); |
| 186 | } |
| 187 | |
| 188 | void DeleteEdges |
| 189 | ( |
no test coverage detected