[graph-tool] wrong label_largest_component

Николай Кинаш peroksid90 at gmail.com
Thu Mar 13 11:45:13 CET 2014


Hello.

import sys, os
from pylab import *
from numpy.random import *
from graph_tool.all import *
g = Graph(directed=False);

N = 10;
v = g.add_vertex();
vlist = [v];
for i in range(1, N):
        v = g.add_vertex()
        c = randint(0, len(vlist))
        target = vlist[c]
        g.add_edge(v, target)
        vlist.append(v)
        if randint(0, 2) == 1:
                rem = randint(0, len(vlist))
                g.remove_vertex( vlist[rem] );

graph_tool.stats.remove_self_loops(g);
pos = sfdp_layout(g, cooling_step=0.99);
graph_draw(g, pos, output_size=(1000, 1000),vertex_size=10,
edge_pen_width=2.2, output="graph" + str(i) + ".png")
l = graph_tool.topology.label_largest_component(g);
print(l.a);
u = graph_tool.topology.GraphView(g, vfilt=l);
print(u.num_vertices());


=============out=======
python test_graph.py
[0 1 1 0 0]
2

but in image i see 4 vertex in largest connected component.

I try it over and over, and always see that 1 or 2 vertex missed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20140313/2f26f18b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graph9.png
Type: image/png
Size: 27794 bytes
Desc: not available
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20140313/2f26f18b/attachment.png>


More information about the graph-tool mailing list