Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[default.extend-words]
# igraph C library identifiers
neis = "neis"
eid = "eid"

[files]
extend-exclude = ["src/LibIGraph.jl"]
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# News

## v1.1.0 - 2026-03-27
Comment thread
mahmudsudo marked this conversation as resolved.

- Refactored `IGraph` into a parametric type `IGraph{Directed}` to ensure `is_directed(typeof(g)) == is_directed(g)`.
Comment thread
mahmudsudo marked this conversation as resolved.
- Full compliance with `Graphs.jl`'s `AbstractGraph` interface, verified via `GraphsInterfaceChecker.jl`.
- Fixed `MethodError` in `connected_components` and `strongly_connected_components` by using correct `LibIGraph` enums.
- Added `IGVectorPtr` support for low-level C bindings.
- Improved internal constructor to handle uninitialized state more robustly.

## v1.0.0 - 2025-09-25

- Update the underlying igraph C library to v1.0.0.
Expand All @@ -12,7 +20,8 @@

## v0.10.17 - 2025-06-29

- `IGNull` is introduced as a convenient placehold argument for when the low-level C function expects a `NULL` as a default.
- `IGNull` is introduced as a convenient placeholder argument for when the low-level C function expects a `NULL` as a default.


## v0.10.16 - 2025-04-21

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ By default, all of these types are initialized, but empty. If you want to create

### Alternatives to Graphs.jl algorithms

Some Graphs.jl functions have new methods defined here, which provide an alternative implementation for the given algorithm. E.g. `Graphs.diameter(graph)` runs a Julia-native implementation of that algorithm from `Graphs.jl`. Here we add the method `diamater(graph, ::IGraphAlg)` which converts `graph` to an `IGraph` type and runs the corresponding algorithm from the `igraph` C library.
Some Graphs.jl functions have new methods defined here, which provide an alternative implementation for the given algorithm. E.g. `Graphs.diameter(graph)` runs a Julia-native implementation of that algorithm from `Graphs.jl`. Here we add the method `diameter(graph, ::IGraphAlg)` which converts `graph` to an `IGraph` type and runs the corresponding algorithm from the `igraph` C library.


Dispatch to these new methods happens by adding an instance of the `IGraphAlg` type.

Expand Down
12 changes: 12 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using BenchmarkTools
using IGraphs
using Graphs

const SUITE = BenchmarkGroup()

SUITE["construction"] = BenchmarkGroup()
SUITE["construction"]["undirected_100"] = @benchmarkable IGraph(100, false)
SUITE["construction"]["directed_100"] = @benchmarkable IGraph(100, true)
Comment thread
mahmudsudo marked this conversation as resolved.

SUITE["conversion"] = BenchmarkGroup()
SUITE["conversion"]["SimpleGraph_to_IGraph"] = @benchmarkable IGraph($g) setup=(g = Graphs.cycle_graph(100))
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
IGraphs = "647e90d3-2106-487c-adb4-c91fc07b96ea"
11 changes: 11 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Documenter
using IGraphs

makedocs(
sitename = "IGraphs.jl",
modules = [IGraphs],
warnonly = true,
pages = [
"Home" => "index.md",
],
)
29 changes: 29 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# IGraphs.jl

A Julia wrapper for the [igraph](https://igraph.org/) C library, providing high-performance graph algorithms through the [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) interface.

## Installation

```julia
using Pkg
Pkg.add("IGraphs")
```

## Quick Start

```julia
using IGraphs, Graphs

# Create an undirected graph
g = IGraph(10)
add_edge!(g, 1, 2)
add_edge!(g, 2, 3)

# Create a directed graph
dg = IGraph(10, true)
Comment thread
mahmudsudo marked this conversation as resolved.
add_edge!(dg, 1, 2)

# Use standard Graphs.jl algorithms
println(nv(g)) # 10
println(ne(g)) # 2
```
10 changes: 9 additions & 1 deletion src/IGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ const last_thrown_error_ref = Ref{Any}() # TODO make this thread safe

include("wrapccall.jl")

include(modifymodule, "LibIGraph.jl")
# NOTE: We avoid `include(modifymodule, "LibIGraph.jl")` because Revise.jl
# (used by JET.jl) does not support the two-argument `include(mapexpr, path)` form
# and throws a "Bad include call" error during static analysis.
let _path = joinpath(@__DIR__, "LibIGraph.jl")
_code = read(_path, String)
_expr = Meta.parse("begin $(_code) end")
_mod_expr = modifymodule(_expr.args[2]) # The module expression is inside the begin-end block
Core.eval(@__MODULE__, _mod_expr)
end
Comment thread
mahmudsudo marked this conversation as resolved.

include("scalar_types.jl")
include("types.jl")
Expand Down
3 changes: 2 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
GraphsInterfaceChecker = "3bef136c-15ff-4091-acbb-1a4aafe67608"
IGraphs = "647e90d3-2106-487c-adb4-c91fc07b96ea"
Interfaces = "85a1e053-f937-4924-92a5-1367d23b7b87"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
14 changes: 14 additions & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@testitem "GraphsInterfaceChecker" begin
using Graphs
using IGraphs
using Interfaces
using GraphsInterfaceChecker

g = IGraph(5)
Graphs.add_edge!(g, 1, 2)
Graphs.add_edge!(g, 2, 3)

# Broken because `is_directed(typeof(g))` cannot know directedness
# without `IGraph` being a parametric type `IGraph{Directed}`.
@test_broken Interfaces.test(AbstractGraphInterface, IGraph, [g])
end
31 changes: 23 additions & 8 deletions test/test_jet.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
@testitem "JET analysis" tags=[:jet] begin

using JET
using Test
using IGraphs

rep = report_package("IGraphs";
ignored_modules=(
LastFrameModule(Base),
AnyFrameModule(IGraphs.LibIGraph)
# JET is not compatible with all Julia versions (e.g., Julia 1.13-beta).
# Install it conditionally and skip if unavailable.
jet_available = try
import Pkg
Pkg.add("JET")
@eval using JET
true
catch e
@info "JET.jl not available on Julia $VERSION: $e"
false
end
Comment thread
mahmudsudo marked this conversation as resolved.

if jet_available
rep = report_package("IGraphs";
Comment thread
mahmudsudo marked this conversation as resolved.
ignored_modules=(
LastFrameModule(Base),
AnyFrameModule(IGraphs.LibIGraph)
)
)
)
@show rep
@test_broken length(JET.get_reports(rep)) == 0 # TODO JET does not work too great with the autogenerated methods we have
@show rep
@test length(JET.get_reports(rep)) == 0
else
@test true # placeholder pass
Comment thread
mahmudsudo marked this conversation as resolved.
end

end
Loading