int addNode(Graph *graph, bool root, HostLabel label) { Node node; node.root = root; node.label = label; node.first_out_edge = -1; node.second_out_edge = -1; node.first_in_edge = -1; node.second_in_edge = -1; node.out_edges = makeIntArray(0); node.in_edges = makeIntArray(0); node.outdegree = 0; node.indegree = 0; node.matched = false; int index = addToNodeArray(&(graph->nodes), node); if(root) addRootNode(graph, index); graph->number_of_nodes++; return index; }
static NodeArray makeNodeArray(int initial_capacity) { NodeArray array; array.capacity = initial_capacity; array.size = 0; array.items = calloc(initial_capacity, sizeof(Node)); if(array.items == NULL) { print_to_log("Error (makeNodeArray): malloc failure.\n"); exit(1); } array.holes = makeIntArray(16); return array; }
Group* makeGroup() { Group* group = malloc(sizeof(Group)); group->words = makeIntArray(6); group->prev = NULL; return group; }