public interface EfficientFilter extends Filter
This is an efficiency measure for handling streams of filters. Sometimes, a program needs to run a series of filters--for example, to cut out all vertices with field "color" is "green" and field "size" is "large". Rather than creating one custom filter that checks both, one can run those two filters serially. The code might look something like this:
Filter f_1 = new ColorFilter( "green" ); Filter f_2 = new SizeFilter( "large "); Graph green_graph = f_1.filter( graph ).assemble(); Graph large_green_graph = f_2.filter( green_graph ).assemble()Unfortunately, assembly can be an expensive process--it requires a full pass through the graph, checking each vertex and each edge. The
EfficientFilter
takes this into account and lets
a user specify the faster parts:
EfficientFilter f_1 = new ColorFilter( "green" ); EfficientFilter f_2 = new SizeFilter( "large "); UnassembledGraph green_u_graph = f_1.filter( graph ); // note: no call to assemble Graph large_green_graph = f_2.filter( green_u_graph ).assemble()which can be simplified to a chain as
EfficientFilter f_1 = new ColorFilter( "green" ); EfficientFilter f_2 = new SizeFilter( "large "); Graph large_green_graph = f_2.filter( f_1.filter( graph )).assemble(); // note: no call to assemble
vertex degree
and
vertex neighbors
are likely to be inaccurate. Thus, the
DropSoloNodesFilter
does not implement EfficientFilter, because it examines the degree of each vertex.
This is taken into consideration correctly for SerialFilter
.
Modifier and Type | Method and Description |
---|---|
UnassembledGraph |
filter(UnassembledGraph ug)
Filters a graph by returning an UnassembledGraph consisting
of nodes and edges that pass the filter.
|
UnassembledGraph filter(UnassembledGraph ug)
Filter
.ug
- An unassembled graph to be filtered.