Alexander Smirnov

[2.3.5] Graph data filtering features

1 post in this topic

There has been some new data filtering features introduced In GraphX version 2.3.5. Let's see the quick review.


  In order to provide more flexible data filtering for GraphX the LogicCore::Filters property has been introduced representing the Queue<IGraphFilter<TVertex, TEdge, TGraph>> of custom filters. The queue means that the filters that are added into it are processed in a FIFO (First In First Out) order consequently modifying the graph. Filters are automaticaly applied on GraphArea::GenerateGraph() and GraphArea::RelayoutGraph() method calls before any visuals are calculated and ensures that all calculations will be done on filtered graph. In case of relayout, each relayout method call will initiate filtering process starting from "original graph". Original graph is the copy of the LogicCore::Graph property that is saved before first filter is applied on an unfiltered graph to have an untouched graph copy.

  Also we'd implemented dynamic visuals add/remove routine specially for the filters in the relayout process so during the each relayout method call GraphX will now check if there are vertices or edges that needs VertexControl/EdgeControl objects to be created/removed to reflect changes made by filters. This behavior can be turned off by setting GraphArea::EnableVisualsRenewOnFiltering property to False.


You can check if graph is currently filtered by checking the LogicCore::IsFiltered property.


Furthermore you have several methods to work with data filtering:

  • LogicCore::PushFilters() - this method is called automaticaly as described above and applies LogicCore::Filters to LogicCore::Graph. You can also call it manually to push the filtering for your custom purpose.
  • LogicCore::ApplyFilters() - this method will remove graph filtering, clear all filters, clear original graph and save filtered graph as unfiltered making the changes permanent. You want to make changes from filtering permanent? That is the method!
  • LogicCore::PopFIlters() - this method will remove graph filtering, clear all filters, clear original graph and revert LogicCore::Graph property to original graph saved earlier. Want to revert all the filtering changes and restore the graph? You can do it!

PS: Remember that while you operate with filtered graph you hold the original graph copy in the memory which can cause performance issues depending on the graph size.


The graph data filter itself is very simple:

    public class BlueVertexFilter: IGraphFilter<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>
        public BidirectionalGraph<DataVertex, DataEdge> ProcessFilter(BidirectionalGraph<DataVertex, DataEdge> inputGraph)
            inputGraph.RemoveVertexIf(a => !a.IsBlue);
            return inputGraph;

It has only one method named ProcessFilter() that do all the stuff. This method receive some graph as the input parameter and shoud return the graph when it is done with the filtering.


So, basically you will want to do the following:

  1. Create custom filters derived from IGraphFilter interface
  2. Add them to LogicCore::FIlters in desired order
  3. Run GraphArea::GenerateGraph() or GraphArea::RelayoutGraph() methods

That's it! If you need this feature functionality expanded please let me know, thanks!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now