Skip to content

Commit a88b584

Browse files
authored
Merge pull request #11 from JuliaGraphs/ignull
introduce IGNull
2 parents 0be10fc + cf468cb commit a88b584

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# News
22

3+
## v0.10.17 - 2025-06-29
4+
5+
- `IGNull` is introduced as a convenient placehold argument for when the low-level C function expects a `NULL` as a default.
6+
37
## v0.10.16 - 2025-04-21
48

59
- `IGVector*` and `IGMatrix*` support the corresponding julia `AbstractArray` interfaces now.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "IGraphs"
22
uuid = "647e90d3-2106-487c-adb4-c91fc07b96ea"
33
authors = ["Stefan Krastanov <stefan@krastanov.org>"]
4-
version = "0.10.16"
4+
version = "0.10.17"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A thin Julia wrapper around the C graphs library [`igraph`](https://igraph.org/)
22

33
### Wrapper types
44

5-
Most C types (like `igraph_vector_int_t`) are directly available in `IGraphs.LibIGraph` and also have Julian wrappers (like `IGVectorInt`).
5+
Most C types (like `igraph_vector_int_t`) are directly available in `IGraphs.LibIGraph` and also have Julian wrappers (like `IGVectorInt`). There is also `IGNull` as a convenient placeholder for whenever the `igraph` C function expects a `NULL` argument.
66

77
### High-level Julian interfaces
88

src/IGraphs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export LibIGraph, IGraph, IGraphException,
88
IGBitSet,
99
#IGraphList,
1010
IGVectorIntList, IGVectorFloatList, IGMatrixFloatList, IGBitSetList,
11-
IGAdjList
11+
IGAdjList,
12+
IGNull
1213

1314
const last_thrown_error_ref = Ref{Any}() # TODO make this thread safe
1415

src/types.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ for (ptr_ctype, jtype) in pairs(wrappedtypes)
6161
end
6262
eval(expr)
6363
end
64+
65+
"""Convenient wrapper for `C_NULL` to be used when `LibIGraph` functions need a `NULL` argument."""
66+
struct IGNull
67+
objref
68+
function IGNull()
69+
return new(C_NULL)
70+
end
71+
end

test/test_assorted_api.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@testitem "Assorted API checks" begin
22

33
import Graphs
4+
using Graphs: ne, nv
45
using IGraphs
56
using Test
67

@@ -17,4 +18,19 @@ using Test
1718
@test collect(v) == [0,2,1,0,1]
1819
end
1920

21+
@testset "NULL input arguments" begin
22+
g = Graphs.smallgraph(:karate)
23+
ig = IGraph(g)
24+
25+
membership = IGVectorInt(zeros(nv(ig)))
26+
membership_null = IGVectorInt(zeros(nv(ig)))
27+
edge_weights = IGVectorFloat(ones(ne(ig)))
28+
node_weights = IGVectorFloat(ones(nv(ig)))
29+
30+
res = LibIGraph.community_leiden(ig, edge_weights, node_weights, 0.05, 0.01, 0, 1, membership)
31+
res_null = LibIGraph.community_leiden(ig, IGNull(), IGNull(), 0.05, 0.01, 0, 1, membership_null)
32+
@test membership == membership_null
33+
@test res == res_null
34+
end
35+
2036
end

0 commit comments

Comments
 (0)