# Getting extra network edges in the plot

**URL:** <https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954>\
**Category:** hvPlot\
**Tags:** bokeh, hvnx, networkx\
**Created:** [February 16, 2023, 8:57am UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954 "2023-02-16T08:57:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rys](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/rys/32/4103_2.png) [@rys](https://discourse.holoviz.org/u/rys)\
**Post date:** [February 16, 2023, 8:57am UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/1 "2023-02-16T08:57:28Z")

</div>

Here is the slightly adapted code from [here](https://hvplot.holoviz.org/user_guide/NetworkX.html#weighted-graph).

```python
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

```

![bokeh_plot3](https://discourse.holoviz.org/uploads/default/original/2X/e/ea2663666a3cc60034827f1eaee5035a8f3388fc.png)  
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. It’s producing knock on effects for me. Will really appreciate any help. Please have a look.

---

<div class="post-metadata">

**Author:** ![rys](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/rys/32/4103_2.png) [@rys](https://discourse.holoviz.org/u/rys)\
**Post date:** [February 16, 2023, 11:23am UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/2 "2023-02-16T11:23:47Z")

</div>

The networkx only generated graph seems to work ok. It’s here [Weighted Graph — NetworkX 3.1rc1.dev0 documentation](https://networkx.org/documentation/latest/auto_examples/drawing/plot_weighted_graph.html#weighted-graph).

But for some reason hvplot or something else is causing this problem. When I use with my example.

---

<div class="post-metadata">

**Author:** ![jbednar](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/jbednar/32/23_2.png) [@jbednar](https://discourse.holoviz.org/u/jbednar)\
**Post date:** [February 20, 2023, 9:00pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/3 "2023-02-20T21:00:33Z")

</div>

If you believe this is a bug, please file an issue on hvplot. Thanks!

---

<div class="post-metadata">

**Author:** ![rys](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/rys/32/4103_2.png) [@rys](https://discourse.holoviz.org/u/rys)\
**Post date:** [February 20, 2023, 9:07pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/4 "2023-02-20T21:07:06Z")

</div>

Do you mean to open an issue on Github? or here on discourse? Thanks

---

<div class="post-metadata">

**Author:** ![jbednar](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/jbednar/32/23_2.png) [@jbednar](https://discourse.holoviz.org/u/jbednar)\
**Post date:** [February 20, 2023, 9:51pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/5 "2023-02-20T21:51:37Z")

</div>

Bugs go on github; discussions go on discourse. [Issues · holoviz/hvplot · GitHub](https://github.com/holoviz/hvplot/issues)  
Thanks!

---

<div class="post-metadata">

**Author:** ![rys](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/rys/32/4103_2.png) [@rys](https://discourse.holoviz.org/u/rys)\
**Post date:** [February 25, 2023, 12:14pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/6 "2023-02-25T12:14:25Z")

</div>

I’ve opened an issue on github. There hasn’t been any update on it or here. I also tried on stackoverflow and got no response. Could you please help to direct it to the right person. I tried reaching to Philipp a week ago but haven’t got a reply yet. Thank you

---

<div class="post-metadata">

**Author:** ![jbednar](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/jbednar/32/23_2.png) [@jbednar](https://discourse.holoviz.org/u/jbednar)\
**Post date:** [February 25, 2023, 10:28pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/7 "2023-02-25T22:28:50Z")

</div>

Please do not ever reach out to a developer personally unless you are offering to hire them for some work. Philipp is not an on-call support person for you or any other user; this is an open-source project offered in the hope that it will be of value, without any warranty or guarantee or promise of support.

As a user, reporting issues is a useful contribution you can make to the project, and fixing them is an even more useful contribution you could make. If fixing it is not something you are able to do, please rest assured that in reporting it you have done your duty, and hopefully at some point other developers will review your issue, attempt to replicate it, and attempt to fix it if it is indeed a bug.

---

<div class="post-metadata">

**Author:** ![rys](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/rys/32/4103_2.png) [@rys](https://discourse.holoviz.org/u/rys)\
**Post date:** [February 26, 2023, 4:55pm UTC](https://discourse.holoviz.org/t/getting-extra-network-edges-in-the-plot/4954/8 "2023-02-26T16:55:27Z")

</div>

Thank you for your patience and intention to help. Looking forward to any update on this. I’ll add it if I find a solution myself but no solution so far. Unsure whether it is infant a bug, i couldn’t locate problem with code. Thanks.
