Modularity weighted layout#
When community labels are known, modularity weighting helps force the layout to better hightlight the community structure. The layout algorithm will weight edges based on whether they are same-community vs cross-community. If no community labels are provided, default to using Louivain.
[ ]:
# ! pip install -q graphistry igraph
[24]:
import graphistry
import pandas as pd
graphistry.register(api=3, username=FILL_ME_IN, password=FILL_ME_IN)
[4]:
df = pd.read_csv('https://raw.githubusercontent.com/graphistry/pygraphistry/master/demos/data/transactions.csv')
g = graphistry.edges(df, 'Destination', 'Source')
[27]:
# Before
g.compute_igraph('community_multilevel', directed=False).plot()
WARNING:graphistry.plugins.igraph:edge index g._edge not set so using edge index as ID; set g._edge via g.edges(), or change merge_if_existing to FalseWARNING:graphistry.plugins.igraph:edge index g._edge __edge_index__ missing as attribute in ig; using ig edge order for IDs
[27]:
[19]:
# After
g2 = g.modularity_weighted_layout(g)
WARNING:graphistry.plugins.igraph:edge index g._edge not set so using edge index as ID; set g._edge via g.edges(), or change merge_if_existing to FalseWARNING:graphistry.plugins.igraph:edge index g._edge __edge_index__ missing as attribute in ig; using ig edge order for IDs
[21]:
g2.plot()
[21]:
[ ]: