cru_filter - specification for selectively removing edges and vertices
#include <cru/cru.h>
typedef struct
cru_filter_s
{
cru_qpred
thinner;
struct
cru_zone_s
fi_zone;
struct
cru_kernel_s
fi_kernel;
struct
cru_order_s
fi_order;
} *cru_filter;
This structure parameterizes the cru_filtered library function with necessary information initialized by the application to remove edges or vertices from a graph selectively based on user-defined criteria. Activities can be restricted to a section of the graph by the cru_zone structure in the fi_zone field. Alternatively, the fi_zone field may be omitted or zero-filled, in which case the whole graph is affected.
For each vertex in the graph, a test property is evaluated according to the structure given by fi_kernel.v_op field with the usual cru_prop calling conventions if one is specified. The interpretation of the test result differs depending on whether the thinner field is specified. The thinner field, if non-NULL, provides further edge filtering functionality explained below following an explanation of the simpler case where the thinner field is NULL. In this case, vertices are kept or removed on this basis:
With regard to edge filtering, if the thinner field is NULL and the fi_kernel.e_op.map field is not, then edges are kept or removed on this basis:
What happens next depends on whether an ordering is defined by the cru_order structure in the fi_order field or whether the field is zero-filled.
If the fi_kernel.e_op.map field is NULL, then no edges are filtered directly but may be deleted as a consequence of being connected to a deleted vertex.
The remainder of this section pertains to filtering when the thinner field refers to a user-defined quarternary predicate.
If the thinner field is defined (i.e., non-NULL), then no vertices are deleted unless they become unreachable. However, the vertices are still tested by the fi_kernel.v_op probe in the same way as above if it is defined. The test result or lack thereof indicates only whether any outgoing edges from the tested vertex should be deleted.
The set of edges or the set of classes of edges obtained as above is then filtered further according to the thinner predicate as follows.
To this end, the application should initialize the thinner field to refer to a relational predicate on edges with the desired effect. That is, it should be antisymmetric and it should return a non-zero value whenever its left operand is preferable to be kept in the graph. As a quarternary predicate, its four operands are an edge label, the terminal vertex of the edge thus labeled, another edge label, and the latter edge's terminus in that order. As always, the predicate must not modify its operands but may assign the error code.
If an ordering is defined by the fi_order field but no edge filter is defined by fi_kernel.e_op field, then an error of CRU_INCFIL is reported by the cru_filtered function, for an inconsistent cru_filter structure.
If an ordering is specified by the fi_kernel.e_order field and a thinner is also specified, then the thinner should be defined consistently with the ordering insofar as equivalent edges under the ordering are also equivalent with respect to the thinner. This condition is necessary because comparison of classes is based on comparison of arbitrarily selected members of the classes. This condition is not enforceable by cru but failure to meet it may lead to non-deterministic results.
This function
uintptr_t even (void *l, uintptr_t vertex, void *r, int *err) { return ! (vertex & 1); }
in this cru_filter
struct cru_filter_s f = { .fi_kernel = { .v_op = { .vertex = { .map = (cru_top) even}}}};
calls for the retention of even numbered vertices in a graph of numerical vertices and the removal of all others, whereas this cru_filter
struct cru_filter_s f = { .fi_kernel = { .e_op = { .map = (cru_top) even}}};
specifies the removal of odd-numbered edges in a graph whose edges are numerically labeled.
It is not impossible for vertices outside of a zone of the graph restricted by the fi_zone to be affected by filtering within the zone.
A cru_filter structure specifying only a thinner field is valid, and calls for all edges except the minimum outgoing edge from each vertex to be deleted.
/usr/local/include/cru/data_types.h
/usr/local/include/cru/error_codes.h
cru, cru_bop, cru_bpred, cru_builder, cru_built, cru_cbop, cru_classifier, cru_class_of, cru_class_size, cru_composed, cru_composer, cru_connect, cru_connector, cru_cqop, cru_crossed, cru_crosser, cru_ctop, cru_ctop_pair, cru_ctop_quad, cru_data_types, cru_deduplicated, cru_destructor, cru_destructor_pair, cru_edge_count, cru_fabricated, cru_fabricator, cru_filtered, cru_fold, cru_free_kill_switch, cru_free_later, cru_free_now, cru_free_partition, cru_function_types, cru_get, cru_hash, cru_induced, cru_inducer, cru_kernel, cru_kill, cru_killed, cru_mapreduced, cru_mapreducer, cru_merged, cru_merger, cru_mutated, cru_mutator, cru_new_kill_switch, cru_nop, cru_order, cru_order_pair, cru_partition_of, cru_plan, cru_postponed, cru_postponer, cru_prop, cru_prop_pair, cru_pruner, cru_qop, cru_qpred, cru_set, cru_sig, cru_singleton, cru_split, cru_splitter, cru_spread, cru_strerror, cru_stretch, cru_stretched, cru_stretcher, cru_subconnector, cru_terminus_count, cru_top, cru_tpred, cru_united, cru_uop, cru_vertex_count, cru_zone
Dennis Furey (milonga@delayinsensitive.com)
https://github.com/gueststar/cru