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

Function Graph_New

src/graph/graph.c:441–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439//------------------------------------------------------------------------------
440
441Graph *Graph_New
442(
443 size_t node_cap,
444 size_t edge_cap
445) {
446
447 fpDestructor cb = (fpDestructor)AttributeSet_Free;
448 Graph *g = rm_calloc(1, sizeof(Graph));
449
450 g->nodes = DataBlock_New(node_cap, node_cap, sizeof(AttributeSet), cb);
451 g->edges = DataBlock_New(edge_cap, edge_cap, sizeof(AttributeSet), cb);
452 g->labels = array_new(RG_Matrix, GRAPH_DEFAULT_LABEL_CAP);
453 g->relations = array_new(RG_Matrix, GRAPH_DEFAULT_RELATION_TYPE_CAP);
454
455 GrB_Info info;
456 UNUSED(info);
457
458 GrB_Index n = Graph_RequiredMatrixDim(g);
459 RG_Matrix_new(&g->node_labels, GrB_BOOL, n, n);
460 RG_Matrix_new(&g->adjacency_matrix, GrB_BOOL, n, n);
461 RG_Matrix_new(&g->adjacency_matrix->transposed, GrB_BOOL, n, n);
462 RG_Matrix_new(&g->_zero_matrix, GrB_BOOL, n, n);
463
464 // init graph statistics
465 GraphStatistics_init(&g->stats);
466
467 // initialize a read-write lock scoped to the individual graph
468 _CreateRWLock(g);
469 g->_writelocked = false;
470
471 // force GraphBLAS updates and resize matrices to node count by default
472 g->SynchronizeMatrix = _MatrixSynchronize;
473
474 return g;
475}
476
477// All graph matrices are required to be squared NXN
478// where N = Graph_RequiredMatrixDim.

Callers 12

GraphContext_NewFunction · 0.85
BuildGraphFunction · 0.85
_fake_graph_contextFunction · 0.85
_fake_graph_contextFunction · 0.85
test_newGraphFunction · 0.85
test_graphConstructionFunction · 0.85
test_removeNodesFunction · 0.85
test_getNodeFunction · 0.85
test_getEdgeFunction · 0.85

Calls 6

rm_callocFunction · 0.85
DataBlock_NewFunction · 0.85
Graph_RequiredMatrixDimFunction · 0.85
RG_Matrix_newFunction · 0.85
GraphStatistics_initFunction · 0.85
_CreateRWLockFunction · 0.85

Tested by 11

BuildGraphFunction · 0.68
_fake_graph_contextFunction · 0.68
_fake_graph_contextFunction · 0.68
test_newGraphFunction · 0.68
test_graphConstructionFunction · 0.68
test_removeNodesFunction · 0.68
test_getNodeFunction · 0.68
test_getEdgeFunction · 0.68