Label components after filtering
Hi, I am trying to label the components of an undirected graph after filtering, but it does not seem to work. Here is a simple example: ---------------------- from graph_tool.all import * Lx = 5 Ly = Lx g = lattice([Lx,Ly]) edges = list(g.edges()) g.remove_edge(edges[4]) g.remove_edge(edges[5]) g.remove_edge(edges[10]) g.remove_edge(edges[13]) g.remove_edge(edges[19]) g.remove_edge(edges[21]) g.remove_edge(edges[22]) g.remove_edge(edges[23]) g.remove_edge(edges[26]) g.remove_edge(edges[35]) g.remove_edge(edges[37]) lscc = label_largest_component(g) gaux = GraphView(g,vfilt=lscc) comp, hist = label_components(gaux) print comp.a ---------------------- The output of the last line is simply a vector containing 25 0's, as if none of the vertices belonged to the largest component, which is not the case, as it can be seen in the attached graph drawing. I found a workaround by creating a new graph and adding to it all the edges of the filtered graph. Was the original approach supposed to work and I am doing something silly? Cheers, Andre Vieira.
On 25.04.2018 20:54, Andre Vieira wrote:
lscc = label_largest_component(g) gaux = GraphView(g,vfilt=lscc) comp, hist = label_components(gaux) print comp.a
The comp.a always returns a pure unfiltered array, which corresponds to the unfiltered graph. To get a filtered array, you have to do print comp.fa which will return an array of length 16, instead of 25. But note that this array will also only contain zeros. But this is correct, as the graph has only one component, which is labeled zero. -- Tiago de Paula Peixoto <tiago@skewed.de>
Thanks! 2018-04-25 18:01 GMT-03:00 Tiago de Paula Peixoto <tiago@skewed.de>:
On 25.04.2018 20:54, Andre Vieira wrote:
lscc = label_largest_component(g) gaux = GraphView(g,vfilt=lscc) comp, hist = label_components(gaux) print comp.a
The comp.a always returns a pure unfiltered array, which corresponds to the unfiltered graph. To get a filtered array, you have to do
print comp.fa
which will return an array of length 16, instead of 25.
But note that this array will also only contain zeros. But this is correct, as the graph has only one component, which is labeled zero.
-- Tiago de Paula Peixoto <tiago@skewed.de> _______________________________________________ graph-tool mailing list graph-tool@skewed.de https://lists.skewed.de/mailman/listinfo/graph-tool
participants (2)
-
Andre Vieira -
Tiago de Paula Peixoto