int main() { igraph_trie_t trie; long int id; int i; char *str; /* init */ igraph_trie_init(&trie, 0); /* add and get values */ igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); igraph_trie_get(&trie, "a", &id); printf("a: %li\n", id); igraph_trie_get(&trie, "axon", &id); printf("axon: %li\n", id); igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); /* check for existence */ igraph_trie_check(&trie, "head", &id); printf("head: %li\n", id); igraph_trie_check(&trie, "alma", &id); printf("alma: %li\n", id); /* destroy */ igraph_trie_destroy(&trie); /* the same with index */ igraph_trie_init(&trie, 1); igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); igraph_trie_get(&trie, "a", &id); printf("a: %li\n", id); igraph_trie_get(&trie, "axon", &id); printf("axon: %li\n", id); igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id); igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id); igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id); igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id); /* check for existence */ igraph_trie_check(&trie, "head", &id); printf("head: %li\n", id); igraph_trie_check(&trie, "alma", &id); printf("alma: %li\n", id); for (i=0; i<igraph_trie_size(&trie); i++) { igraph_trie_idx(&trie, i, &str); printf("%d: %s\n", i, str); } igraph_trie_destroy(&trie); if (!IGRAPH_FINALLY_STACK_EMPTY) return 1; return 0; }
void igraph_i_graphml_sax_handler_start_document(void *state0) { struct igraph_i_graphml_parser_state *state= (struct igraph_i_graphml_parser_state*)state0; int ret; state->st=START; state->successful=1; state->edges_directed=0; state->destroyed=0; state->data_key=0; state->error_message=0; state->data_char=0; ret=igraph_vector_ptr_init(&state->v_attrs, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_vector_ptr_destroy, &state->v_attrs); ret=igraph_vector_ptr_init(&state->e_attrs, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_vector_ptr_destroy, &state->e_attrs); ret=igraph_vector_ptr_init(&state->g_attrs, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_vector_ptr_destroy, &state->g_attrs); ret=igraph_vector_init(&state->edgelist, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_vector_destroy, &state->edgelist); ret=igraph_trie_init(&state->node_trie, 1); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_trie_destroy, &state->node_trie); ret=igraph_strvector_init(&state->edgeids, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_strvector_destroy, &state->edgeids); ret=igraph_trie_init(&state->v_names, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_trie_destroy, &state->v_names); ret=igraph_trie_init(&state->e_names, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_trie_destroy, &state->e_names); ret=igraph_trie_init(&state->g_names, 0); if (ret) { igraph_error("Cannot parse GraphML file", __FILE__, __LINE__, ret); igraph_i_graphml_sax_handler_error(state, "Cannot parse GraphML file"); return; } IGRAPH_FINALLY(igraph_trie_destroy, &state->g_names); IGRAPH_FINALLY_CLEAN(9); IGRAPH_FINALLY(igraph_i_graphml_destroy_state, state); }