holoviz / holoviz/hvplot

Getting extra edges in hvplot+networkx (hvnx)

Open
#1,024 0 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

Using this example from [here](https://hvplot.holoviz.org/user_guide/NetworkX.html#weighted-graph) when modified slightly, it results in extra edges being drawn.
#### ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
Python 3.8

#### Description of expected behavior and the observed behavior
Edge (c, d) should not be solid in this case, and Edge (a, d) (needs closer look to see) should not be dashed according to the logic. But the result show these extra edges which shouldn’t be there according to condition. Please have a look.
#### Complete, minimal, self-contained example code that reproduces the issue

```
# Here is the code
import networkx as nx
import hvplot.networkx as hvnx

G = nx.DiGraph()

G.add_edge('a', 'b', Polarity=0.1)
G.add_edge('a', 'c', Polarity=0.1)
G.add_edge('c', 'd', Polarity=0.1)
G.add_edge('c', 'e', Polarity=0.6)
G.add_edge('c', 'f', Polarity=0.6)
G.add_edge('a', 'd', Polarity=0.6)

elarge = [(u, v) for (u, v, attr) in G.edges(data=True) if attr['Polarity'] > 0.5]
esmall = [(u, v) for (u, v, attr) in G.edges(data=True) if attr['Polarity'] <= 0.5]

pos = nx.spring_layout(G) # positions for all nodes

# nodes
nodes = hvnx.draw_networkx_nodes(G, pos, node_size=700)

# edges
edges1 = hvnx.draw_networkx_edges(
G, pos, edgelist=elarge, edge_width=6)
edges2 = hvnx.draw_networkx_edges(
G, pos, edgelist=esmall, edge_width=6, alpha=0.5, edge_color='blue', style='dashed')
labels = hvnx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')

edges1 * edges2 * nodes * labels
```

#### Stack traceback and/or browser JavaScript console output

#### Screenshots or screencasts of the bug in action
![image](https://user-images.githubusercontent.com/105497256/220935722-1fd2e731-7763-4ef6-96fe-b53a5cb93832.png)

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.