[graph-tool] Building (and working with) bipartite graphs

Tiago de Paula Peixoto tiago at skewed.de
Thu Jul 9 16:45:06 CEST 2020


Am 09.07.20 um 14:37 schrieb Davide Cittaro:> I'm pretty sure this is
not the most efficient way to go, but gt.is_bipartite(g) returns True.
Can anybody suggest a more straightforward approach? Also, is it
necessary to specify a VertexPropertyMap with node type (i.e. M or N)?
You're probably better off with doing something like:

   idx = adjacency.nonzero()
   edges = array([idx[0], idx[1], adjacency[idx]]).T
   edges[:,1] += edges[:,0].max() + 1 # offset bipartition
   g.add_edge_list(edges, eprops=[weight])

> Anyhow, after I had the graph and the final model, I tried to draw:
> 
> gt.draw_hierarchy(state, layout='bipartite')
> 
> but I get this error

In order for us to investigate further you need to provide us with a
minimal working example, not only the error message.

Best,
Tiago
-- 
Tiago de Paula Peixoto <tiago at skewed.de>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20200709/f9487c53/attachment.asc>


More information about the graph-tool mailing list