Displaying Overlapping Communities for Networks Without Clustering with SBMs

Hi, I am trying to generate plots for communities detected by another
algorithm (outside graph-tool). The communities are overlapping and I wanted
to display something like nodes with multiple colors (like we have for
SBMs). For this I set a new vertex property and assign nodal memberships to
it. I assign a matrix which contains one hot vectors for each node's
community membership. So the matrix has shape n x g where n is the number of
nodes and g is the number of communities. When I use graph_draw like:

graph_draw(g, vertex_shape="pie", vertex_pie_fractions=pv,
edge_gradient=None, output="lesmis-sbm-marginals.svg")

where pv is the property map, I get: python3:
../../../../src/cairo-arc.c:189: _cairo_arc_in_direction: Assertion
`angle_max >= angle_min' failed.

I want to show overlapping clusters with graph-tool, but the clustering
hasn't been performed by graph-tool.

Any ideas as to how to go about this?

Thanks!

You're probably just passing the wrong type to vertex_pie_fractions, but we
have no way to know that as we're missing the minimal self-contained
example.

.~´

attachment.html (2.13 KB)

This should reproduce the error:
g = Graph()
v1 = g.add_vertex()
v2 = g.add_vertex()
e = g.add_edge(v1, v2)
pv1 = g.new_vertex_property("vector<int>");
pv1.set_2d_array(np.zeros((2, 2)))
graph_draw(g, vertex_shape="pie", vertex_pie_fractions=pv1,
edge_gradient=None, output="lesmis-sbm-marginals.svg")

Why do you want pies with all zero fractions? What would that accomplish?

You should be doing something like:

   g = Graph()
   v1 = g.add_vertex()
   v2 = g.add_vertex()
   e = g.add_edge(v1, v2)
   pv1 = g.new_vertex_property("vector<double>", val=(.2, .8))
   graph_draw(g, vertex_shape="pie", vertex_pie_fractions=pv1)

But I agree it should not crash if the input is invalid. I'll fix this behavior.

Best,
Tiago

So if I want a vertex to have multiple colors (fractions), what should the
pv1 look like? Please look at my question description.

Thanks,
Sukrit

This should reproduce the error:
g = Graph()
v1 = g.add_vertex()
v2 = g.add_vertex()
e = g.add_edge(v1, v2)
pv1 = g.new_vertex_property("vector<int>");
pv1.set_2d_array(np.zeros((2, 2)))
graph_draw(g, vertex_shape="pie", vertex_pie_fractions=pv1,
edge_gradient=None, output="lesmis-sbm-marginals.svg")

Why do you want pies with all zero fractions? What would that accomplish?

You should be doing something like:

   g = Graph()
   v1 = g.add_vertex()
   v2 = g.add_vertex()
   e = g.add_edge(v1, v2)
   pv1 = g.new_vertex_property("vector<double>", val=(.2, .8))
   graph_draw(g, vertex_shape="pie", vertex_pie_fractions=pv1)

But I agree it should not crash if the input is invalid. I'll fix this
behavior.

Best,
Tiago

attachment.html (2.07 KB)

I don't know how to make this any clearer. It should contain a value for
each fraction:

   pv[g.vertex(0)] = [.3, .6, .1] # 30% with color 0, 60% with color 1, 10% with color 2

Thanks, Tiago. The issue was the fact that when you added vertices which
did not have any clusters associated with them (isolated nodes), there was
an error. This behavior should be fixed, if possible.

Sukrit

attachment.html (2.89 KB)