Commit e97f5ee1 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix bug in vertex/edge filter initialization in Graph.__init__()

parent aad493dd
......@@ -147,48 +147,22 @@ check_filtered(const Graph &g, const EdgeFilter& edge_filter,
if (max_eindex > 0)
edge_filter.reserve(max_eindex);
if (v_active)
{
if (num_vertices(g) > 0)
vertex_filter.reserve(num_vertices(g));
typedef filtered_graph<Graph, MaskFilter<EdgeFilter>,
MaskFilter<VertexFilter> > fg_t;
fg_t init(g, e_filter, v_filter);
fg_t& fg = retrieve_graph(graph_views, init);
fg.m_edge_pred = e_filter;
fg.m_vertex_pred = v_filter;
return check_directed(fg, reverse, directed, graph_views);
}
else
{
typedef filtered_graph<Graph, MaskFilter<EdgeFilter>,
keep_all> fg_t;
fg_t init(g, e_filter, keep_all());
fg_t& fg = retrieve_graph(graph_views, init);
fg.m_edge_pred = e_filter;
return check_directed(fg, reverse, directed, graph_views);
}
if (num_vertices(g) > 0)
vertex_filter.reserve(num_vertices(g));
typedef filtered_graph<Graph, MaskFilter<EdgeFilter>,
MaskFilter<VertexFilter> > fg_t;
fg_t init(g, e_filter, v_filter);
fg_t& fg = retrieve_graph(graph_views, init);
fg.m_edge_pred = e_filter;
fg.m_vertex_pred = v_filter;
return check_directed(fg, reverse, directed, graph_views);
}
else
{
if (v_active)
{
if (!e_active)
throw GraphException("Vertex filter is active but edge filter is not. This is a bug.");
if (num_vertices(g) > 0)
vertex_filter.reserve(num_vertices(g));
typedef filtered_graph<Graph, keep_all,
MaskFilter<VertexFilter> > fg_t;
fg_t init(g, keep_all(), v_filter);
fg_t& fg = retrieve_graph(graph_views, init);
fg.m_vertex_pred = v_filter;
return check_directed(fg, reverse, directed, graph_views);
}
else
{
return check_directed(g, reverse, directed, graph_views);
}
throw GraphException("Vertex filter is active but edge filter is not. This is a bug.");
return check_directed(g, reverse, directed, graph_views);
}
#else
return check_directed(g, reverse, directed, graph_views);
......@@ -306,6 +280,8 @@ void GraphInterface::SetVertexFilterProperty(boost::any property, bool invert)
}
catch(bad_any_cast&)
{
if (!property.empty())
throw GraphException("Invalid vertex filter property!");
_vertex_filter_active = false;
}
}
......@@ -325,6 +301,8 @@ void GraphInterface::SetEdgeFilterProperty(boost::any property, bool invert)
}
catch(bad_any_cast&)
{
if (!property.empty())
throw GraphException("Invalid edge filter property!");
_edge_filter_active = false;
}
}
......@@ -1183,7 +1183,7 @@ class Graph(object):
for k, m in gv.edge_properties.items():
if not m.is_writable():
m = m.copy("int32_t")
if not eprune and m is efilt:
if not eprune and m is efilt:
ef_pos = len(eprops)
eprops.append([_prop("e", gv, m), libcore.any()])
if not vprune and vf_pos is None and vfilt is not None:
......@@ -1232,12 +1232,12 @@ class Graph(object):
vpmap = new_vertex_property("bool",
self.__graph.GetVertexIndex(),
vprops[vf_pos][1])
vpmap = PropertyMap(pmap, self, "v")
vpmap = PropertyMap(vpmap, self, "v")
if ef_pos is not None:
epmap = new_edge_property("bool",
self.__graph.GetEdgeIndex(),
eprops[ef_pos][1])
epmap = PropertyMap(pmap, self, "e")
epmap = PropertyMap(epmap, self, "e")
self.set_filters(epmap, vpmap,
inverted_edges=g.get_edge_filter()[1],
inverted_vertices=g.get_vertex_filter()[1])
......
Supports Markdown
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