holoviz / holoviz/hvplot

Process edge attributes from networks graph based on user kwargs

Open
#1,331 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

#### Is your feature request related to a problem? Please describe.
This is my use case - I have a geodataframe with a bunch of linestring geometry. While I can visualize that with geodataframe.hvplot, I do want to show the network topology (arrows etc), so felt ploting a networkx directed graph might be better. So I used momepy.gdf_to_nx. This either returns a DiGraph or a MultiDiGraph, and converts all columns of the gdf to attributes of the graph. For my purposes a DiGraph seems sufficient. I also want to color the edges and show some attributes on hover (thanks to all the posts on ispection policy and hovertools I am able to achieve this). Since there is a geometry attribute in my initial gdf, I get an error when I visualize this graph - TypeError: '<' not supported between instances of 'LineString' and 'LineString'. [Entire stack trace is here](https://pastebin.com/Fj1aKPyF).

#### Describe the solution you'd like
I think there are a few ways to get around this, all with some changes in the [from_networkx function](https://github.com/holoviz/hvplot/blob/47f89eed102acd5b55094ff6e691672664b68aef/hvplot/networkx.py#L49):

1. Ensure we only parse through types which can be compared (and not avoid just list/dict).
2. Let the user specify edge attributes (as a list and passed in as a kwarg) from the graph to parse into the holoview Graph object.

#### Additional context
Initially I was using the defaults in momepy.gdf_to_nx and it returns a MultiDiGraph, which stores attributes one level deeper, so supporting that would also involve the keyword approach along with checking the type of graph.

There is a from_networkx function in hvplot.networkx as well as in holoviews graph.py which both seem replicas of each other, so we may have to make changes in the best possible location.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.