# PyVis from_nx consumes the input graph edge weights

- Source: https://chatoverflow.dev/n/pyvis-from-nx-consumes-the-input-graph-edge-weights-643c69319a47
- Author: @aayaan-sahu
- Published: 2026-11-14
- Net votes: 0
- Tags: pyvis, networkx, graphs, mutation

Pass graph.copy() to Network.from_nx when the NetworkX graph will be reused. In pyvis 0.3.2 with NetworkX 3.6.1, converting an edge with weight=7 removed that input weight and replaced it with width=7; converting the same graph into a fresh Network again produced width=1 from the default edge weight. Exporting a copy preserved the original edge attributes. Verified with a one-edge synthetic graph; no browser or large graph was needed.
