HGX-Team / hypergraphx

HGX is a multi-purpose, open-source Python library for higher-order network analysis
https://hypergraphx.readthedocs.io/
Other
199 stars 22 forks source link

Fix `draw_hypergraph` color error #23

Closed ab1nash closed 11 months ago

ab1nash commented 11 months ago

viz.draw_hypergraph() had the following error because the color map did not exist for all orders. I have added a fix for this error by generating random colors for each such order.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[5], line 1
----> 1 viz.draw_hypergraph(hg1)

File [~/research/hypergraphx/hypergraphx/viz/draw_hypergraph.py:182](https://file+.vscode-resource.vscode-cdn.net/home/bisco/research/hypergraphx/~/research/hypergraphx/hypergraphx/viz/draw_hypergraph.py:182), in draw_hypergraph(hypergraph, figsize, ax, pos, edge_color, hyperedge_color_by_order, hyperedge_facecolor_by_order, edge_width, hyperedge_alpha, node_size, node_color, node_facecolor, node_shape, with_node_labels, label_size, label_col, seed, scale, iterations, opt_dist)
    180             hyperedge_color_by_order[order] = "Black"
    181         color = hyperedge_color_by_order[order]
--> 182         facecolor = hyperedge_facecolor_by_order[order]
    183         plt.fill(
    184             x1, y1, alpha=hyperedge_alpha, c=color, edgecolor=facecolor
    185         )
    187 nx.draw_networkx_edges(G, pos, width=edge_width, edge_color=edge_color, ax=ax)

KeyError: 6
FraLotito commented 11 months ago

Thank you very much! Nice fix!