Commit 00d1e489 authored by Tiago Peixoto's avatar Tiago Peixoto

included option to disable python and range filtering during compilation, thus...

included option to disable python and range filtering during compilation, thus reducing compile-time memory requirements


git-svn-id: https://svn.forked.de/graph-tool/trunk@64 d4600afd-f417-0410-95de-beed9576f240
parent aca4479d
......@@ -99,6 +99,21 @@ AC_ARG_ENABLE([static-linkage], [AC_HELP_STRING([--enable-static-linkage],
[AC_MSG_RESULT(no)] )
AM_CONDITIONAL(STATIC, test $STATIC = yes)
AC_MSG_CHECKING(whether to enable graph filtering...)
AC_ARG_ENABLE([filtering], [AC_HELP_STRING([--disable-filtering],
[disable graph filtering (range and python only) [default=no] ])],
if test $enableval = no; then
[AC_MSG_RESULT(no)]
[AC_DEFINE([NO_FILTERING], 1, [disable graph filtering])]
NO_FILTERING=yes
else
[AC_MSG_RESULT(yes)]
fi
,
[AC_MSG_RESULT(yes)]
NO_FILTERING=no
)
dnl Checks for programs.
dnl Checks for libraries.
......
......@@ -91,6 +91,7 @@ GraphInterface::~GraphInterface()
void GraphInterface::SetVertexFilterProperty(string property)
{
#ifndef NO_FILTERING
_vertex_filter_property = property;
if (property != "")
......@@ -117,12 +118,16 @@ void GraphInterface::SetVertexFilterProperty(string property)
throw GraphException("property " + property + " not found");
}
}
#else
throw GraphException("support for graph filtering was not enabled during compilation.");
#endif
}
bool GraphInterface::IsVertexFilterActive() const { return _vertex_filter_property != "" || _vertex_python_filter != python::object(); }
void GraphInterface::SetEdgeFilterProperty(string property)
{
#ifndef NO_FILTERING
_edge_filter_property = property;
if (property != "")
......@@ -149,10 +154,42 @@ void GraphInterface::SetEdgeFilterProperty(string property)
throw GraphException("property " + property + " not found");
}
}
#else
throw GraphException("support for graph filtering was not enabled during compilation.");
#endif
}
bool GraphInterface::IsEdgeFilterActive() const {return _edge_filter_property != "" || _edge_python_filter != python::object();}
void GraphInterface::SetVertexFilterRange(std::pair<double,double> allowed_range)
{
#ifndef NO_FILTERING
_vertex_range = allowed_range;
#else
throw GraphException("support for graph filtering was not enabled during compilation.");
#endif
}
void GraphInterface::SetGenericVertexFilter(boost::python::object filter)
{
#ifndef NO_FILTERING
_vertex_python_filter = filter;
#else
throw GraphException("support for graph filtering was not enabled during compilation.");
#endif
}
void GraphInterface::SetGenericEdgeFilter(boost::python::object filter)
{
#ifndef NO_FILTERING
_edge_python_filter = filter;
#else
throw GraphException("support for graph filtering was not enabled during compilation.");
#endif
}
//==============================================================================
// GetNumberOfVertices()
......
......@@ -119,7 +119,7 @@ public:
void SetVertexFilterProperty(std::string property);
std::string GetVertexFilterProperty() const {return _vertex_filter_property;}
void SetVertexFilterRange(std::pair<double,double> allowed_range) {_vertex_range = allowed_range;}
void SetVertexFilterRange(std::pair<double,double> allowed_range);
std::pair<double, double> GetVertexFilterRange() const {return _vertex_range;}
bool IsVertexFilterActive() const;
......@@ -129,8 +129,8 @@ public:
std::pair<double,double> GetEdgeFilterRange() const {return _edge_range;}
bool IsEdgeFilterActive() const;
void SetGenericVertexFilter(boost::python::object filter) {_vertex_python_filter = filter;}
void SetGenericEdgeFilter(boost::python::object filter) {_edge_python_filter = filter;}
void SetGenericVertexFilter(boost::python::object filter);
void SetGenericEdgeFilter(boost::python::object filter);
// modification
void RemoveEdgeProperty(std::string property);
......
......@@ -242,11 +242,13 @@ void check_python_filter(const Graph& g, const GraphInterface &gi, Action a, boo
template <class Action, class ReverseCheck, class DirectedCheck>
void check_filter(const GraphInterface &g, Action a, ReverseCheck, DirectedCheck)
{
bool found = false;
#ifndef NO_FILTERING
typedef RangeFilter<GraphInterface::vertex_filter_map_t> vertex_filter_t;
typedef RangeFilter<GraphInterface::edge_filter_map_t> edge_filter_t;
bool found = false;
if (g._edge_python_filter == python::object() && g._vertex_python_filter == python::object())
{
if (g._vertex_filter_property != "" && g._edge_filter_property != "")
......@@ -277,9 +279,14 @@ void check_filter(const GraphInterface &g, Action a, ReverseCheck, DirectedCheck
check_python_filter(g._mg, g, a, found, ReverseCheck(), DirectedCheck());
}
#else
mpl::for_each<DirectedCheck>(check_directed<GraphInterface::multigraph_t,Action,ReverseCheck>(g._mg, a, g._reversed, g._directed, found));
#endif
if (!found)
throw GraphException("graph filtering error: filter not found");
}
} //graph_tool namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment