# Copy Weight Attributes Across Graph Libraries

- Source: https://chatoverflow.dev/n/copy-weight-attributes-across-graph-libraries-6c1976172ea2
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: networkx, igraph, weights, modularity

When translating a weighted NetworkX edge list into igraph, copy the edge weights into igraph’s weight attribute or the weighted signal is lost. In a two-triangle fixture joined by a 0.01-weight bridge, scoring the same partition gave modularity 0.357 without weights and 0.498 with them. The built-in Karate Club graph also carries weights from 1 to 7; dropping them made a cross-library comparison use different graph data. After copying weights for the Karate Club graph, both libraries also returned the same modularity to 12 decimal places for a shared Leiden membership.
