Skip to content

Commit 208f44b

Browse files
committed
NetworkX to NetworkXGraphs
1 parent e8dec44 commit 208f44b

6 files changed

Lines changed: 267 additions & 19 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name = "NetworkX"
1+
name = "NetworkXGraphs"
22
uuid = "7cfbcbcf-cd41-4fe6-b90f-527da21b4c9a"
33
version = "0.1.0"
44
authors = ["Jash <jashambaliya1@gmail.com>"]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# NetworkX.jl
1+
# NetworkXGraphs.jl
22

3-
`NetworkX.jl` is a Julia wrapper around Python's `networkx` built on `PythonCall.jl`.
3+
`NetworkXGraphs.jl` is a Julia wrapper around Python's `networkx` built on `PythonCall.jl`.
44
The current milestone is intentionally narrow: constructors plus the basic `Graphs.jl` API needed to pass `GraphsInterfaceChecker`.
55

66
`networkx` is declared as a package dependency and is automatically installed via `CondaPkg.jl` — no manual Python setup required.
@@ -9,18 +9,18 @@ The current milestone is intentionally narrow: constructors plus the basic `Grap
99

1010
- Wrap `networkx.Graph`/`networkx.DiGraph` as `Graphs.AbstractGraph` using the `NetworkXGraph` / `NetworkXDiGraph` constructors
1111
- Convert between `Graphs.jl` graph types and Python `networkx` objects via `networkx_graph`
12-
- Access the raw Python `networkx` module through `NetworkX.PythonNetworkX`
12+
- Access the raw Python `networkx` module through `NetworkXGraphs.PythonNetworkX`
1313
- Validate interface conformance with `GraphsInterfaceChecker.jl`
1414
- Stress-test multi-threaded use of independent graphs to catch Python/GIL integration regressions
1515

1616
## Quick start
1717

1818
```julia
1919
using Graphs
20-
using NetworkX
20+
using NetworkXGraphs
2121

2222
# Access the raw Python networkx module
23-
nx = NetworkX.PythonNetworkX.networkx
23+
nx = NetworkXGraphs.PythonNetworkX.networkx
2424

2525
# Create a Python networkx graph and wrap it as a Graphs.jl-compatible graph
2626
pyg = nx.path_graph(5)

src/NetworkX.jl renamed to src/NetworkXGraphs.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module NetworkX
1+
module NetworkXGraphs
22

33
using Graphs
44
using PythonCall: Py, pynew, pycopy!, pybuiltins, pyconvert, pyimport
@@ -10,16 +10,16 @@ export AbstractNetworkXGraph,
1010
refresh_index!
1111

1212
"""
13-
NetworkX.PythonNetworkX
13+
NetworkXGraphs.PythonNetworkX
1414
1515
Sub-module providing direct access to the Python `networkx` package.
1616
Use this namespace when you need raw Python networkx objects or algorithms
1717
that are not yet wrapped by the Julia API.
1818
1919
# Example
2020
```julia
21-
using NetworkX
22-
nx = NetworkX.PythonNetworkX.networkx
21+
using NetworkXGraphs
22+
nx = NetworkXGraphs.PythonNetworkX.networkx
2323
pyg = nx.complete_graph(5)
2424
```
2525
"""
@@ -49,8 +49,8 @@ Wrap an undirected Python `networkx.Graph` as a `Graphs.AbstractGraph`.
4949
5050
# Example
5151
```julia
52-
using NetworkX
53-
nx = NetworkX.PythonNetworkX.networkx
52+
using NetworkXGraphs
53+
nx = NetworkXGraphs.PythonNetworkX.networkx
5454
pyg = nx.path_graph(5)
5555
gw = NetworkXGraph(pyg)
5656
```
@@ -69,8 +69,8 @@ Wrap a directed Python `networkx.DiGraph` as a `Graphs.AbstractGraph`.
6969
7070
# Example
7171
```julia
72-
using NetworkX
73-
nx = NetworkX.PythonNetworkX.networkx
72+
using NetworkXGraphs
73+
nx = NetworkXGraphs.PythonNetworkX.networkx
7474
pyg = nx.DiGraph()
7575
pyg.add_edges_from([(1, 2), (2, 3)])
7676
gw = NetworkXDiGraph(pyg)
@@ -281,4 +281,4 @@ function Base.reverse(g::NetworkXDiGraph{T}) where {T<:Integer}
281281
return reversed
282282
end
283283

284-
end # module NetworkX
284+
end # module NetworkXGraphs

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
33
GraphsInterfaceChecker = "3bef136c-15ff-4091-acbb-1a4aafe67608"
44
Interfaces = "85a1e053-f937-4924-92a5-1367d23b7b87"
5-
NetworkX = "7cfbcbcf-cd41-4fe6-b90f-527da21b4c9a"
5+
NetworkXGraphs = "7cfbcbcf-cd41-4fe6-b90f-527da21b4c9a"
66
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
77
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ using Base.Threads: nthreads
44
using Graphs
55
using GraphsInterfaceChecker
66
using Interfaces
7-
using NetworkX
7+
using NetworkXGraphs
88
using PythonCall
99

10-
@testset "NetworkX.jl" begin
11-
nx = NetworkX.PythonNetworkX.networkx
10+
@testset "NetworkXGraphs.jl" begin
11+
nx = NetworkXGraphs.PythonNetworkX.networkx
1212

1313
@testset "Constructors and basic API" begin
1414
pyg = nx.Graph()

test_out.txt

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
Updating registry at `~/.julia/registries/General.toml`
2+
Updating `~/Documents/NetworkX.jl/Project.toml`
3+
[992eb4ea] + CondaPkg v0.2.34
4+
[86223c79] + Graphs v1.14.0
5+
[6099a3de] + PythonCall v0.9.31
6+
Updating `~/Documents/NetworkX.jl/Manifest.toml`
7+
[ec485272] + ArnoldiMethod v0.4.0
8+
[992eb4ea] + CondaPkg v0.2.34
9+
[9a962f9c] + DataAPI v1.16.0
10+
[864edb3b] + DataStructures v0.19.4
11+
[e2d170a0] + DataValueInterfaces v1.0.0
12+
[86223c79] + Graphs v1.14.0
13+
[d25df0c9] + Inflate v0.1.5
14+
[82899510] + IteratorInterfaceExtensions v1.0.0
15+
[692b3bcd] + JLLWrappers v1.7.1
16+
[682c06a0] + JSON v1.5.1
17+
[1914dd2f] + MacroTools v0.5.16
18+
[0b3b1443] + MicroMamba v0.1.15
19+
[bac558e1] + OrderedCollections v1.8.1
20+
[69de0a69] + Parsers v2.8.4
21+
[fa939f87] + Pidfile v1.3.0
22+
[aea7be01] + PrecompileTools v1.3.3
23+
[21216c6a] + Preferences v1.5.2
24+
[6099a3de] + PythonCall v0.9.31
25+
[6c6a2e73] + Scratch v1.3.0
26+
[699a6c99] + SimpleTraits v0.9.5
27+
[90137ffa] + StaticArrays v1.9.18
28+
[1e83bf80] + StaticArraysCore v1.4.4
29+
[10745b16] + Statistics v1.11.1
30+
[ec057cc2] + StructUtils v2.8.0
31+
[3783bdb8] + TableTraits v1.0.1
32+
[bd369af6] + Tables v1.12.1
33+
[e17b2a0c] + UnsafePointers v1.0.0
34+
[f8abcde7] + micromamba_jll v2.3.1+0
35+
[4d7b5844] + pixi_jll v0.41.3+0
36+
[0dad84c5] + ArgTools v1.1.2
37+
[56f22d72] + Artifacts v1.11.0
38+
[2a0f44e3] + Base64 v1.11.0
39+
[ade2ca70] + Dates v1.11.0
40+
[f43a241f] + Downloads v1.7.0
41+
[7b1f6079] + FileWatching v1.11.0
42+
[b77e0a4c] + InteractiveUtils v1.11.0
43+
[ac6e5ff7] + JuliaSyntaxHighlighting v1.12.0
44+
[4af54fe1] + LazyArtifacts v1.11.0
45+
[b27032c2] + LibCURL v0.6.4
46+
[76f85450] + LibGit2 v1.11.0
47+
[8f399da3] + Libdl v1.11.0
48+
[37e2e46d] + LinearAlgebra v1.12.0
49+
[56ddb016] + Logging v1.11.0
50+
[d6f4376e] + Markdown v1.11.0
51+
[ca575930] + NetworkOptions v1.3.0
52+
[44cfe95a] + Pkg v1.12.1
53+
[de0858da] + Printf v1.11.0
54+
[9a3f8284] + Random v1.11.0
55+
[ea8e919c] + SHA v0.7.0
56+
[9e88b42a] + Serialization v1.11.0
57+
[2f01184e] + SparseArrays v1.12.0
58+
[f489334b] + StyledStrings v1.11.0
59+
[fa267f1f] + TOML v1.0.3
60+
[a4e569a6] + Tar v1.10.0
61+
[8dfed614] + Test v1.11.0
62+
[cf7118a7] + UUIDs v1.11.0
63+
[4ec0a83e] + Unicode v1.11.0
64+
[e66e0078] + CompilerSupportLibraries_jll v1.3.0+1
65+
[deac9b47] + LibCURL_jll v8.15.0+0
66+
[e37daf67] + LibGit2_jll v1.9.0+0
67+
[29816b5a] + LibSSH2_jll v1.11.3+1
68+
[14a3606d] + MozillaCACerts_jll v2025.5.20
69+
[4536629a] + OpenBLAS_jll v0.3.29+0
70+
[458c3c95] + OpenSSL_jll v3.5.4+0
71+
[bea87d4a] + SuiteSparse_jll v7.8.3+2
72+
[83775a58] + Zlib_jll v1.3.1+2
73+
[8e850b90] + libblastrampoline_jll v5.15.0+0
74+
[8e850ede] + nghttp2_jll v1.64.0+1
75+
[3f19e933] + p7zip_jll v17.7.0+0
76+
Testing NetworkXGraphs
77+
Status `/tmp/jl_tKQl1D/Project.toml`
78+
[86223c79] Graphs v1.14.0
79+
[3bef136c] GraphsInterfaceChecker v0.1.0
80+
[85a1e053] Interfaces v0.3.2
81+
[7cfbcbcf] NetworkXGraphs v0.1.0 `~/Documents/NetworkX.jl`
82+
[6099a3de] PythonCall v0.9.31
83+
[8dfed614] Test v1.11.0
84+
Status `/tmp/jl_tKQl1D/Manifest.toml`
85+
[ec485272] ArnoldiMethod v0.4.0
86+
[992eb4ea] CondaPkg v0.2.34
87+
[9a962f9c] DataAPI v1.16.0
88+
[864edb3b] DataStructures v0.19.4
89+
[e2d170a0] DataValueInterfaces v1.0.0
90+
[86223c79] Graphs v1.14.0
91+
[3bef136c] GraphsInterfaceChecker v0.1.0
92+
[d25df0c9] Inflate v0.1.5
93+
[85a1e053] Interfaces v0.3.2
94+
[82899510] IteratorInterfaceExtensions v1.0.0
95+
[692b3bcd] JLLWrappers v1.7.1
96+
[682c06a0] JSON v1.5.1
97+
[1914dd2f] MacroTools v0.5.16
98+
[0b3b1443] MicroMamba v0.1.15
99+
[7cfbcbcf] NetworkXGraphs v0.1.0 `~/Documents/NetworkX.jl`
100+
[bac558e1] OrderedCollections v1.8.1
101+
[69de0a69] Parsers v2.8.4
102+
[fa939f87] Pidfile v1.3.0
103+
[aea7be01] PrecompileTools v1.3.3
104+
[21216c6a] Preferences v1.5.2
105+
[6099a3de] PythonCall v0.9.31
106+
[6c6a2e73] Scratch v1.3.0
107+
[699a6c99] SimpleTraits v0.9.5
108+
[90137ffa] StaticArrays v1.9.18
109+
[1e83bf80] StaticArraysCore v1.4.4
110+
[10745b16] Statistics v1.11.1
111+
[ec057cc2] StructUtils v2.8.0
112+
[3783bdb8] TableTraits v1.0.1
113+
[bd369af6] Tables v1.12.1
114+
[e17b2a0c] UnsafePointers v1.0.0
115+
[f8abcde7] micromamba_jll v2.3.1+0
116+
[4d7b5844] pixi_jll v0.41.3+0
117+
[0dad84c5] ArgTools v1.1.2
118+
[56f22d72] Artifacts v1.11.0
119+
[2a0f44e3] Base64 v1.11.0
120+
[ade2ca70] Dates v1.11.0
121+
[f43a241f] Downloads v1.7.0
122+
[7b1f6079] FileWatching v1.11.0
123+
[b77e0a4c] InteractiveUtils v1.11.0
124+
[ac6e5ff7] JuliaSyntaxHighlighting v1.12.0
125+
[4af54fe1] LazyArtifacts v1.11.0
126+
[b27032c2] LibCURL v0.6.4
127+
[76f85450] LibGit2 v1.11.0
128+
[8f399da3] Libdl v1.11.0
129+
[37e2e46d] LinearAlgebra v1.12.0
130+
[56ddb016] Logging v1.11.0
131+
[d6f4376e] Markdown v1.11.0
132+
[ca575930] NetworkOptions v1.3.0
133+
[44cfe95a] Pkg v1.12.1
134+
[de0858da] Printf v1.11.0
135+
[9a3f8284] Random v1.11.0
136+
[ea8e919c] SHA v0.7.0
137+
[9e88b42a] Serialization v1.11.0
138+
[2f01184e] SparseArrays v1.12.0
139+
[f489334b] StyledStrings v1.11.0
140+
[fa267f1f] TOML v1.0.3
141+
[a4e569a6] Tar v1.10.0
142+
[8dfed614] Test v1.11.0
143+
[cf7118a7] UUIDs v1.11.0
144+
[4ec0a83e] Unicode v1.11.0
145+
[e66e0078] CompilerSupportLibraries_jll v1.3.0+1
146+
[deac9b47] LibCURL_jll v8.15.0+0
147+
[e37daf67] LibGit2_jll v1.9.0+0
148+
[29816b5a] LibSSH2_jll v1.11.3+1
149+
[14a3606d] MozillaCACerts_jll v2025.5.20
150+
[4536629a] OpenBLAS_jll v0.3.29+0
151+
[458c3c95] OpenSSL_jll v3.5.4+0
152+
[bea87d4a] SuiteSparse_jll v7.8.3+2
153+
[83775a58] Zlib_jll v1.3.1+2
154+
[8e850b90] libblastrampoline_jll v5.15.0+0
155+
[8e850ede] nghttp2_jll v1.64.0+1
156+
[3f19e933] p7zip_jll v17.7.0+0
157+
Precompiling for configuration --code-coverage=none --color=auto --check-bounds=yes --warn-overwrite=yes --depwarn=yes --inline=yes --startup-file=no --track-allocation=none
158+
19676.9 ms ✓ NetworkXGraphs
159+
1 dependency successfully precompiled in 20 seconds. 67 already precompiled.
160+
1 dependency had output during precompilation:
161+
┌ NetworkXGraphs
162+
│ CondaPkg Found dependencies: /home/jash/.julia/packages/PythonCall/83z4q/CondaPkg.toml
163+
│ CondaPkg Found dependencies: /home/jash/.julia/packages/CondaPkg/8GjrP/CondaPkg.toml
164+
│ CondaPkg Found dev dependencies: /home/jash/Documents/NetworkX.jl/CondaPkg.toml
165+
│ CondaPkg Resolving changes
166+
│ + libstdcxx
167+
│ + libstdcxx-ng
168+
│ + networkx
169+
│ + openssl
170+
│ + python
171+
│ CondaPkg Initialising pixi
172+
│ │ /home/jash/.julia/artifacts/cefba4912c2b400756d043a2563ef77a0088866b/bin/pixi
173+
│ │ init
174+
│ │ --format pixi
175+
│ └ /tmp/jl_tKQl1D/.CondaPkg
176+
│ ✔ Created /tmp/jl_tKQl1D/.CondaPkg/pixi.toml
177+
│ CondaPkg Wrote /tmp/jl_tKQl1D/.CondaPkg/pixi.toml
178+
│ │ [dependencies]
179+
│ │ openssl = ">=3, <3.6"
180+
│ │ libstdcxx = ">=3.4,<15.0"
181+
│ │ libstdcxx-ng = ">=3.4,<15.0"
182+
│ │ networkx = "*"
183+
│ │
184+
│ │ [dependencies.python]
185+
│ │ channel = "conda-forge"
186+
│ │ build = "*cp*"
187+
│ │ version = ">=3.10,!=3.14.0,!=3.14.1,<4"
188+
│ │
189+
│ │ [project]
190+
│ │ name = ".CondaPkg"
191+
│ │ platforms = ["linux-64"]
192+
│ │ channels = ["conda-forge"]
193+
│ │ channel-priority = "strict"
194+
│ └ description = "automatically generated by CondaPkg.jl"
195+
│ CondaPkg Installing packages
196+
│ │ /home/jash/.julia/artifacts/cefba4912c2b400756d043a2563ef77a0088866b/bin/pixi
197+
│ │ install
198+
│ └ --manifest-path /tmp/jl_tKQl1D/.CondaPkg/pixi.toml
199+
│ ✔ The default environment has been installed.
200+
201+
Testing Running tests...
202+
203+
Testing AbstractGraphInterface is implemented for NetworkXGraph
204+
205+
Mandatory components
206+
is_directed: (`is_directed` outputs a boolean [true, true])
207+
edgetype: (`edgetype` outputs a type [true, true])
208+
vertices: (`vertices` is coherent with `eltype` [true, true],
209+
every vertex in `vertices(g)` exists [true, true],
210+
vertices beyond `vertices(g)` don't exist [true, true])
211+
edges: (`edges` is coherent with `edgetype` [true, true],
212+
every edge in `edges` exists [true, true],
213+
`edges` are symmetric for undirected graphs [true, true])
214+
nv: (`nv` outputs an integer` [true, true],
215+
`nv` is coherent with `vertices` [true, true])
216+
ne: (`ne` outputs an integer` [true, true],
217+
`ne` is coherent with `edges` [true, true])
218+
neighbors: (`inneighbors` is coherent with `has_edge` [true, true],
219+
`outneighbors` is coherent with `has_edge` [true, true],
220+
`inneighbors` and `outneighbors` coincide for undirected graphs [true, true])
221+
weights: (`weights` outputs a matrix of real numbers [true, true],
222+
`weights` has the right size [true, true],
223+
`weights` are symmetric for undirected graphs [true, true])
224+
225+
Testing AbstractGraphInterface is implemented for NetworkXDiGraph
226+
227+
Mandatory components
228+
is_directed: (`is_directed` outputs a boolean [true, true])
229+
edgetype: (`edgetype` outputs a type [true, true])
230+
vertices: (`vertices` is coherent with `eltype` [true, true],
231+
every vertex in `vertices(g)` exists [true, true],
232+
vertices beyond `vertices(g)` don't exist [true, true])
233+
edges: (`edges` is coherent with `edgetype` [true, true],
234+
every edge in `edges` exists [true, true],
235+
`edges` are symmetric for undirected graphs [true, true])
236+
nv: (`nv` outputs an integer` [true, true],
237+
`nv` is coherent with `vertices` [true, true])
238+
ne: (`ne` outputs an integer` [true, true],
239+
`ne` is coherent with `edges` [true, true])
240+
neighbors: (`inneighbors` is coherent with `has_edge` [true, true],
241+
`outneighbors` is coherent with `has_edge` [true, true],
242+
`inneighbors` and `outneighbors` coincide for undirected graphs [true, true])
243+
weights: (`weights` outputs a matrix of real numbers [true, true],
244+
`weights` has the right size [true, true],
245+
`weights` are symmetric for undirected graphs [true, true])
246+
Test Summary: | Pass Total Time
247+
NetworkXGraphs.jl | 38 38 11.5s
248+
Testing NetworkXGraphs tests passed

0 commit comments

Comments
 (0)