gpatches
A tool to diff two graphs. This library helps you identify changes between two networkx graphs including added/removed nodes, changed node parameters, and added/removed edges.
Installation
pip install gpatches
Usage
import networkx as nx
from gpatches import diff_graphs
G1 = nx.DiGraph()
G1.add_node("A", x=1, y=2)
G1.add_node("B", foo="bar")
G1.add_edge("A", "B", weight=5)
G2 = nx.DiGraph()
G2.add_node("A", x=1, y=3, z=4) # Changed y value and added z parameter
G2.add_node("C", color="blue") # New node
G2.add_edge("A", "C", weight=2) # New edge
# Diff the graphs
patches = diff_graphs(G1, G2)
print(patches)
The output from the above example would be:
GraphPatch(
added_nodes={'C': {'color': 'blue'}},
removed_nodes={'B': {'foo': 'bar'}},
changed_nodes={
'A': NodePatch(
added_params={'z': 4},
removed_params={},
changed_params={'y': ParamPatch(old_param_value=2, new_param_value=3)}
)
},
removed_edges={('A', 'B'): {'weight': 5}},
added_edges={('A', 'C'): {'weight': 2}}
)
Metadata
Release files for gpatches 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gpatches-0.1.1.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpatches-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.6 kB
Release files / gpatches-0.1.1.tar.gz
| Download URL | gpatches-0.1.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
788f51b407b4283a713b2815d8a64057d5ce3e5bf6b470b8310da0cadb454b26
|
|
BLAKE2b-256 checksum How to use checksums |
9c45c519ace132459d228128c76d7d3bcf76d2bc67f0d9d24e2ebb2c6e8475d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.12
|
Release files / gpatches-0.1.1-py3-none-any.whl
| Download URL | gpatches-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
141b5433840307f76f04a54671f8dd95b290d98521a3e5bbc9d8e406e89c319d
|
|
BLAKE2b-256 checksum How to use checksums |
7ee39b234239bf53e6bc946f2c6624fc67883159a0d98f1a16e8110f99ad86e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.12
|