MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / labeled_edge_count

Function labeled_edge_count

tests/test_pipeline.c:1939–1965  ·  view source on GitHub ↗

Edges of `edge_type` from the node named `source_name` to the node named * `target_name` that carries `target_label`. */

Source from the content-addressed store, hash-verified

1937/* Edges of `edge_type` from the node named `source_name` to the node named
1938 * `target_name` that carries `target_label`. */
1939static int labeled_edge_count(cbm_store_t *s, const char *project, const char *edge_type,
1940 const char *source_name, const char *target_name,
1941 const char *target_label) {
1942 cbm_edge_t *edges = NULL;
1943 int edge_count = 0;
1944 if (cbm_store_find_edges_by_type(s, project, edge_type, &edges, &edge_count) != CBM_STORE_OK) {
1945 return -1;
1946 }
1947 int matches = 0;
1948 for (int i = 0; i < edge_count; i++) {
1949 cbm_node_t source = {0};
1950 cbm_node_t target = {0};
1951 int source_ok = cbm_store_find_node_by_id(s, edges[i].source_id, &source) == CBM_STORE_OK;
1952 int target_ok = cbm_store_find_node_by_id(s, edges[i].target_id, &target) == CBM_STORE_OK;
1953 if (source_ok && target_ok && source.name && target.name && target.label &&
1954 strcmp(source.name, source_name) == 0 && strcmp(target.name, target_name) == 0 &&
1955 strcmp(target.label, target_label) == 0) {
1956 matches++;
1957 }
1958 cbm_node_free_fields(&source);
1959 cbm_node_free_fields(&target);
1960 }
1961 if (edges) {
1962 cbm_store_free_edges(edges, edge_count);
1963 }
1964 return matches;
1965}
1966
1967/* A Java field and a same-named method of one class keep their own nodes (the
1968 * field is fenced `<Owner>.<name>#field`), and a write or a read of the field

Callers 1

test_pipeline.cFile · 0.85

Calls 4

cbm_node_free_fieldsFunction · 0.85
cbm_store_free_edgesFunction · 0.85

Tested by

no test coverage detected