graph_analysis
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
graph_analysis::Filter< FilterObject > Class Template Reference

Filter for a graph. More...

#include <Filter.hpp>

Inheritance diagram for graph_analysis::Filter< FilterObject >:
Inheritance graph
[legend]

Public Types

typedef Filter< FilterObject > FilterType
 
typedef shared_ptr< FilterType > Ptr
 
typedef std::vector< FilterType::Ptr > FilterList
 

Public Member Functions

virtual ~Filter ()
 
virtual std::string getName () const
 Get Name of the filter. More...
 
virtual std::string toString () const
 Get string representation of filter. More...
 
int replace (FilterType::Ptr filter, int position=-1)
 
void clear ()
 
int add (FilterType::Ptr filter, int position=-1)
 
void removeAt (int position)
 
bool matches (FilterObject o, filters::Operator op=filters::OR) const
 Apply all filters, i.e. root filter and children to the filter object, i.e., test whether filter matches the filter object. More...
 
virtual bool apply (FilterObject o) const
 Apply only the main filter(!) to the target object. More...
 

Static Public Member Functions

static Ptr Null ()
 

Protected Attributes

FilterList mFilters
 

Detailed Description

template<typename FilterObject>
class graph_analysis::Filter< FilterObject >

Filter for a graph.

Allow definition of a filter per object type. Object type should inherit from Vertex or Edge

This filter class allows bagging of multiple individual filters into a single filter object

class SpecialVertexFilter : public Filter< Vertex::Ptr >
{
public:
    virtual std::string getName() const { return "SpecialVertexFilter"; }
    virtual bool apply(Vertex::Ptr element) const
    {
        return element->getClassName() == "SpecialVertex";
    }
};

 BaseGraph::Ptr graph = BaseGraph::getInstance();
 ...
 SubGraph::Ptr subGraph = BaseGraph::getSubGraph(graph);
 Filter< Vertex::Ptr >::Ptr vertexFilter(new SpecialVertexFilter());
 Filter< Edge::Ptr >::Ptr edgeFilter(new filters::PermitAll< Edge::Ptr >());
 subGraph->applyFilters(vertexFilter, edgeFilter);

 // Convert to base graph when you want to use the graph with any of the
 // available algorithms
 BaseGraph::ptr filteredGraph = subGraph->toBaseGraph();

Member Typedef Documentation

◆ FilterList

template<typename FilterObject >
typedef std::vector< FilterType::Ptr > graph_analysis::Filter< FilterObject >::FilterList

◆ FilterType

template<typename FilterObject >
typedef Filter<FilterObject> graph_analysis::Filter< FilterObject >::FilterType

◆ Ptr

template<typename FilterObject >
typedef shared_ptr<FilterType> graph_analysis::Filter< FilterObject >::Ptr

Constructor & Destructor Documentation

◆ ~Filter()

template<typename FilterObject >
virtual graph_analysis::Filter< FilterObject >::~Filter ( )
inlinevirtual

Deconstructor

Member Function Documentation

◆ add()

template<typename FilterObject >
int graph_analysis::Filter< FilterObject >::add ( FilterType::Ptr  filter,
int  position = -1 
)
inline

Add a filter

Parameters
filterFilter to add
positionPosition of the filter
Returns
position of filter

◆ apply()

template<typename FilterObject >
virtual bool graph_analysis::Filter< FilterObject >::apply ( FilterObject  o) const
inlinevirtual

Apply only the main filter(!) to the target object.

Parameters
oFilter object, i.e. target object to apply the filter on
Returns
True, if the main filter matches the target/filter object, false otherwise

Reimplemented in graph_analysis::filters::RegexFilter< T >, graph_analysis::filters::RegexFilter< ::graph_analysis::Vertex::Ptr >, and graph_analysis::filters::RegexFilter< ::graph_analysis::Edge::Ptr >.

◆ clear()

template<typename FilterObject >
void graph_analysis::Filter< FilterObject >::clear ( )
inline

Clears the list of additional filters that have been added to this filter

◆ getName()

template<typename FilterObject >
virtual std::string graph_analysis::Filter< FilterObject >::getName ( ) const
inlinevirtual

◆ matches()

template<typename FilterObject >
bool graph_analysis::Filter< FilterObject >::matches ( FilterObject  o,
filters::Operator  op = filters::OR 
) const
inline

Apply all filters, i.e. root filter and children to the filter object, i.e., test whether filter matches the filter object.

Parameters
oFilterObject, i.e. target that requires evaluation
opChain the subfilter dis/con-junctively using available operators OR and AND
Returns
for OR: True if this item is matched by any of the filters, for AND: True if this item is matched by all of the filters, false otherwise

◆ Null()

template<typename FilterObject >
static Ptr graph_analysis::Filter< FilterObject >::Null ( )
inlinestatic

Return Null Filter

◆ removeAt()

template<typename FilterObject >
void graph_analysis::Filter< FilterObject >::removeAt ( int  position)
inline

◆ replace()

template<typename FilterObject >
int graph_analysis::Filter< FilterObject >::replace ( FilterType::Ptr  filter,
int  position = -1 
)
inline

Replace a filter at a certain position in the internally kept filter list This might be needed to update a filter

Parameters
filterFilter to replace the existing one with
positionPosition of the filter that should be replaced, if position -1 is given the filter is added without replacing another
Exceptions
std::out_of_rangeif the position does not exist

◆ toString()

template<typename FilterObject >
virtual std::string graph_analysis::Filter< FilterObject >::toString ( ) const
inlinevirtual

Member Data Documentation

◆ mFilters

template<typename FilterObject >
FilterList graph_analysis::Filter< FilterObject >::mFilters
protected

The documentation for this class was generated from the following file: