Hi Tiago,

Yes, your approach works in my case, and below I give the code.

But imagine a graph consisting of a 4-clique and a 5-ring overlapping in one 
node:

edgelist = np.array([[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [0, 4], 
[4, 5], [5, 6], [6, 7], [0, 7]])
G = Graph(directed=False)
G.add_edge_list(edgelist)

In this case your proposed method to extract the vertices with edges labeled 
the most frequent number doesn't work. Is there a universal recipe?

This is the way to extract the largest bicomponent in a working example:

# create graph
edgelist = np.array([[ 0,  1], [ 0,  3], [ 0,  5], [ 0,  9], [ 1,  2], [ 1,  
4], [ 1,  5], [ 1,  8], [ 1, 16], [ 1, 17], [ 1, 23], [ 3,  5], [ 3, 19], [ 5,  
6], [ 5,  9], [ 5, 11], [ 5, 13], [ 6,  7], [ 6, 10], [ 8, 12], [ 8, 21], [ 9, 
15], [ 9, 22], [11, 13], [13, 14], [13, 21], [15, 20], [15, 24], [17, 18]])
G = Graph(directed=False)
G.add_edge_list(edgelist)
# extract largest bicomponent
bicomp, articulation, nc = label_biconnected_components(G)
l = []
for i in list(bicomp.a == 16):
    l.append(bool(i))
edge_filter = G.new_edge_property('bool')
edge_filter.a = l
G.set_edge_filter(edge_filter)
m = label_largest_component(G)
G = GraphView(G, vfilt=m)
G.num_vertices()

Best

Haiko
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to