Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No More Sadness and Despair for Hierarchical Edge Bundling with Python. #122

Closed
paulbrodersen opened this issue Feb 3, 2022 · 2 comments

Comments

@paulbrodersen
Copy link
Contributor

If you're aware of any tip to build it, please let me knwo!

I built and maintain a python library for network visualisation called netgraph.
Netgraph accepts igraph and networkx Graph objects as input (as well as many other sensible data structures to represent graphs in python).

For edge bundling, netgraph implements the FDEB algorithm proposed by Holten & Wijk (2009).

Example visualization that combines a modular node layout with edge bundling:

import matplotlib.pyplot as plt
import networkx as nx

from netgraph import Graph # pip install netgraph

# create a modular graph
partition_sizes = [10, 20, 30, 40]
g = nx.random_partition_graph(partition_sizes, 0.5, 0.1)

# position nodes according to their community using the `community` node layout
node_to_community = dict()
node = 0
for community_id, size in enumerate(partition_sizes):
    for _ in range(size):
        node_to_community[node] = community_id
        node += 1

# color nodes according to their community
community_to_color = {
    0 : 'tab:blue',
    1 : 'tab:orange',
    2 : 'tab:green',
    3 : 'tab:red',
}
node_color = {node: community_to_color[community_id] for node, community_id in node_to_community.items()}

Graph(g,
      node_color=node_color, node_edge_width=0, edge_alpha=0.1,
      node_layout='community', node_layout_kwargs=dict(node_to_community=node_to_community),
      edge_layout='bundled', edge_layout_kwargs=dict(k=2000),
)

plt.show()

community_layout

@holtzy
Copy link
Owner

holtzy commented Feb 15, 2022

This is very very cool, thanks for your message!! I definitely have to add it to the website.

I don't have the bandwidth right now to do so, but it will happen for sure.

Would you be interested in writing a jupyter notebook that describes this feature more in depth and make a PR? It could help promote your work!

Thanks again for reaching out.

@paulbrodersen
Copy link
Contributor Author

Sure, can do. Apart from the code example above, what else would you like to see in the notebook?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants