| 1359 | } |
| 1360 | |
| 1361 | static void _Graph_Free |
| 1362 | ( |
| 1363 | Graph *g, |
| 1364 | bool is_full_graph |
| 1365 | ) { |
| 1366 | ASSERT(g); |
| 1367 | // free matrices |
| 1368 | AttributeSet *set; |
| 1369 | DataBlockIterator *it; |
| 1370 | |
| 1371 | RG_Matrix_free(&g->_zero_matrix); |
| 1372 | RG_Matrix_free(&g->adjacency_matrix); |
| 1373 | |
| 1374 | _Graph_FreeRelationMatrices(g); |
| 1375 | array_free(g->relations); |
| 1376 | GraphStatistics_FreeInternals(&g->stats); |
| 1377 | |
| 1378 | uint32_t labelCount = array_len(g->labels); |
| 1379 | for(int i = 0; i < labelCount; i++) RG_Matrix_free(&g->labels[i]); |
| 1380 | array_free(g->labels); |
| 1381 | RG_Matrix_free(&g->node_labels); |
| 1382 | |
| 1383 | it = is_full_graph ? Graph_ScanNodes(g) : DataBlock_FullScan(g->nodes); |
| 1384 | while((set = (AttributeSet *)DataBlockIterator_Next(it, NULL)) != NULL) { |
| 1385 | if(*set != NULL) { |
| 1386 | AttributeSet_Free(set); |
| 1387 | } |
| 1388 | } |
| 1389 | DataBlockIterator_Free(it); |
| 1390 | |
| 1391 | it = is_full_graph ? Graph_ScanEdges(g) : DataBlock_FullScan(g->edges); |
| 1392 | while((set = DataBlockIterator_Next(it, NULL)) != NULL) { |
| 1393 | if(*set != NULL) { |
| 1394 | AttributeSet_Free(set); |
| 1395 | } |
| 1396 | } |
| 1397 | DataBlockIterator_Free(it); |
| 1398 | |
| 1399 | |
| 1400 | // free blocks |
| 1401 | DataBlock_Free(g->nodes); |
| 1402 | DataBlock_Free(g->edges); |
| 1403 | |
| 1404 | int res; |
| 1405 | UNUSED(res); |
| 1406 | |
| 1407 | if(g->_writelocked) Graph_ReleaseLock(g); |
| 1408 | res = pthread_rwlock_destroy(&g->_rwlock); |
| 1409 | ASSERT(res == 0); |
| 1410 | |
| 1411 | rm_free(g); |
| 1412 | } |
| 1413 | |
| 1414 | void Graph_Free |
| 1415 | ( |
no test coverage detected