Loading src/graph/graph.cc +5 −6 Original line number Diff line number Diff line Loading @@ -52,26 +52,25 @@ GraphInterface::~GraphInterface() // this will get the number of vertices, either the "soft" O(1) way, or the hard // O(V) way, which is necessary if the graph is filtered size_t GraphInterface::GetNumberOfVertices() size_t GraphInterface::GetNumberOfVertices(bool filtered) { size_t n = 0; if (IsVertexFilterActive()) if (filtered && IsVertexFilterActive()) run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(HardNumVertices(),lambda::_1))(); else run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(SoftNumVertices(),lambda::_1))(); n = num_vertices(*_mg); return n; } // this will get the number of edges, either the "soft" O(E) way, or the hard // O(E) way, which is necessary if the graph is filtered. Both cases are of // linear complexity, since num_edges() is O(E) in Boost's adjacency_list size_t GraphInterface::GetNumberOfEdges() size_t GraphInterface::GetNumberOfEdges(bool filtered) { using namespace boost::lambda; size_t n = 0; if (IsEdgeFilterActive() || IsVertexFilterActive()) if (filtered && (IsEdgeFilterActive() || IsVertexFilterActive())) run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(HardNumEdges(),lambda::_1))(); else Loading src/graph/graph.hh +2 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ public: // Basic manipulation // size_t GetNumberOfVertices(); size_t GetNumberOfEdges(); size_t GetNumberOfVertices(bool filtered = true); size_t GetNumberOfEdges(bool filtered = true); void SetDirected(bool directed) {_directed = directed;} bool GetDirected() {return _directed;} void SetReversed(bool reversed) {_reversed = reversed;} Loading src/graph_tool/__init__.py +6 −13 Original line number Diff line number Diff line Loading @@ -493,22 +493,17 @@ class PropertyMap(object): """ a = self._get_data() if a is None: return None raise ValueError("Cannot get array for value type: " + self.value_type()) return PropertyArray(a, prop_map=self) def _get_data(self): g = self.get_graph() if g is None: return None if g.get_edge_filter() is not None or g.get_vertex_filter() is not None: u = GraphView(g, skip_properties=True, skip_efilt=True, skip_vfilt=True) else: u = g raise ValueError("Cannot get array for an orphaned property map") if self.__key_type == 'v': n = u.num_vertices() n = g._Graph__graph.GetNumberOfVertices(False) elif self.__key_type == 'e': n = max(u.max_edge_index, 1) n = g.max_edge_index else: n = 1 a = self.__map.get_array(n) Loading @@ -516,8 +511,6 @@ class PropertyMap(object): def __set_array(self, v): a = self.get_array() if a is None: return a[:] = v a = property(get_array, __set_array, Loading Loading @@ -2109,7 +2102,7 @@ class Graph(object): If the vertices are being filtered, this operation is :math:`O(N)`. Otherwise it is :math:`O(1)`. """ return self.__graph.GetNumberOfVertices() return self.__graph.GetNumberOfVertices(True) def num_edges(self): """Get the number of edges. Loading @@ -2119,7 +2112,7 @@ class Graph(object): If the edges are being filtered, this operation is :math:`O(E)`. Otherwise it is :math:`O(1)`. """ return self.__graph.GetNumberOfEdges() return self.__graph.GetNumberOfEdges(True) # Pickling support # ================ Loading Loading
src/graph/graph.cc +5 −6 Original line number Diff line number Diff line Loading @@ -52,26 +52,25 @@ GraphInterface::~GraphInterface() // this will get the number of vertices, either the "soft" O(1) way, or the hard // O(V) way, which is necessary if the graph is filtered size_t GraphInterface::GetNumberOfVertices() size_t GraphInterface::GetNumberOfVertices(bool filtered) { size_t n = 0; if (IsVertexFilterActive()) if (filtered && IsVertexFilterActive()) run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(HardNumVertices(),lambda::_1))(); else run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(SoftNumVertices(),lambda::_1))(); n = num_vertices(*_mg); return n; } // this will get the number of edges, either the "soft" O(E) way, or the hard // O(E) way, which is necessary if the graph is filtered. Both cases are of // linear complexity, since num_edges() is O(E) in Boost's adjacency_list size_t GraphInterface::GetNumberOfEdges() size_t GraphInterface::GetNumberOfEdges(bool filtered) { using namespace boost::lambda; size_t n = 0; if (IsEdgeFilterActive() || IsVertexFilterActive()) if (filtered && (IsEdgeFilterActive() || IsVertexFilterActive())) run_action<>()(*this, lambda::var(n) = lambda::bind<size_t>(HardNumEdges(),lambda::_1))(); else Loading
src/graph/graph.hh +2 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ public: // Basic manipulation // size_t GetNumberOfVertices(); size_t GetNumberOfEdges(); size_t GetNumberOfVertices(bool filtered = true); size_t GetNumberOfEdges(bool filtered = true); void SetDirected(bool directed) {_directed = directed;} bool GetDirected() {return _directed;} void SetReversed(bool reversed) {_reversed = reversed;} Loading
src/graph_tool/__init__.py +6 −13 Original line number Diff line number Diff line Loading @@ -493,22 +493,17 @@ class PropertyMap(object): """ a = self._get_data() if a is None: return None raise ValueError("Cannot get array for value type: " + self.value_type()) return PropertyArray(a, prop_map=self) def _get_data(self): g = self.get_graph() if g is None: return None if g.get_edge_filter() is not None or g.get_vertex_filter() is not None: u = GraphView(g, skip_properties=True, skip_efilt=True, skip_vfilt=True) else: u = g raise ValueError("Cannot get array for an orphaned property map") if self.__key_type == 'v': n = u.num_vertices() n = g._Graph__graph.GetNumberOfVertices(False) elif self.__key_type == 'e': n = max(u.max_edge_index, 1) n = g.max_edge_index else: n = 1 a = self.__map.get_array(n) Loading @@ -516,8 +511,6 @@ class PropertyMap(object): def __set_array(self, v): a = self.get_array() if a is None: return a[:] = v a = property(get_array, __set_array, Loading Loading @@ -2109,7 +2102,7 @@ class Graph(object): If the vertices are being filtered, this operation is :math:`O(N)`. Otherwise it is :math:`O(1)`. """ return self.__graph.GetNumberOfVertices() return self.__graph.GetNumberOfVertices(True) def num_edges(self): """Get the number of edges. Loading @@ -2119,7 +2112,7 @@ class Graph(object): If the edges are being filtered, this operation is :math:`O(E)`. Otherwise it is :math:`O(1)`. """ return self.__graph.GetNumberOfEdges() return self.__graph.GetNumberOfEdges(True) # Pickling support # ================ Loading