Skip to content

edge_weights does not reflect edges added after construction #431

Description

@sgrava

edge_weights does not reflect edges added after construction

Description

DataGraph._edge_weights is populated by _reset_dicts(), which is called only at construction time. Since add_edges_from is inherited from NetworkX and does not update _edge_weights, any edges added after construction are missing from edge_weights with no error or warning.

Root cause

BaseGraph._reset_dicts seeds _edge_weights from sorted_edges once, at construction. Subsequent add_edges_from calls go directly to the NetworkX layer and bypass _reset_dicts.
Minimum reproducible example

from qoolqit.graphs.data_graph import DataGraph

g = DataGraph.from_nodes([0, 1, 2])
g.add_edges_from([(0, 1), (1, 2)])

print(g.edge_weights)  # {} — expected {(0, 1): None, (1, 2): None}

Expected behaviour
{(0, 1): None, (1, 2): None}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions