Am 06.01.20 um 13:53 schrieb Gerion Entrup: > Hi, > > the documentation describes that GraphView can be given a unary function > to filter vertices or edges. > > I have tried that and it seems to fail. My GraphView has not the > expected vertices and edges. > > However, my assumption is that the filter is only evaluated one time > (at initialization). > > Let me make an example: > > ``` > g = graph_tool.Graph() > a = graph_tool.GraphView(g, vfilt=...) > > fill_the_graph(g) > do_stuff_with(a) # <- here a does not contain any data > ``` > > From the documentation, it seems that graph_tool constructs a property > from the filter function and uses this for filtering (therefore also > needing O(N)), but fill this property only on construction. Can you > mention this in the documentation as a hint or warning?
Right, this is entirely expected behavior. It seems obvious to me in the documentation, but I will make it more explicit. Note that it would be completely unreasonable performance-wise to populate the filter property map lazily on demand. Note also that if you had modified `a` instead of `g` in your example, the filtering would behave as expected (i.e. new vertices or edges would appear in the graph view). > Maybe also a recalculate function for GraphView is meaningful that > evaluates the lambda function again. I don't think this is good design. GraphViews are supposed to be cheap objects that can be constructed on demand. If the filtering needs to be re-done, then a new GraphView should be constructed, maybe even composed from the older one. I.e. in your example you would re-create `a` after you had modified `g`. Best, Tiago -- Tiago de Paula Peixoto <[email protected]> _______________________________________________ graph-tool mailing list [email protected] https://lists.skewed.de/mailman/listinfo/graph-tool
