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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pkg> add NautyGraphs
## Basic Usage
NautyGraphs.jl defines the `NautyGraph` or `NautyDiGraph` graph formats, which can be constructed and modified in the same way as regular `Graphs` from Graphs.jl:
```julia
using NautyGraphs, Graphs
using NautyGraphs

A = [0 1 0 0;
1 0 1 1;
Expand Down
4 changes: 1 addition & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Pkg; Pkg.add("Graphs")

using Documenter, NautyGraphs

DocMeta.setdocmeta!(NautyGraphs, :DocTestSetup, :(using NautyGraphs, Graphs); recursive=true)
DocMeta.setdocmeta!(NautyGraphs, :DocTestSetup, :(using NautyGraphs); recursive=true)

makedocs(sitename="NautyGraphs.jl";
pages = [
Expand Down
2 changes: 1 addition & 1 deletion docs/src/graph_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ are intrinsically compatible with _nauty_, performing isomorphism checks or grap
`NautyGraphs` and `NautyDiGraphs` can be created in the same way as graphs from `Graphs.jl`. As an example, here are three different ways to define the same graph:

```jldoctest default
using NautyGraphs, Graphs
using NautyGraphs

A = [0 1 0 0;
1 0 1 1;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pkg> add NautyGraphs
## Basic Usage
NautyGraphs.jl defines the `NautyGraph` or `NautyDiGraph` graph formats, which can be constructed and modified in the same way as regular `Graphs` from Graphs.jl:
```jldoctest intro; output=false
using NautyGraphs, Graphs
using NautyGraphs

A = [0 1 0 0;
1 0 1 1;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/isomorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The _nauty_ library actually does not solve the graph isomorphsim problem direct

To see what this looks like in practice, let's first construct two unequal, but isomorphic graphs:
```jldoctest isomorph
using NautyGraphs, Graphs
using NautyGraphs
g1 = NautyGraph([Edge(1, 2), Edge(2, 3), Edge(2, 4), Edge(3, 4)])
g2 = g1[[3, 2, 4, 1]] # permute the vertices of g1

Expand Down
21 changes: 19 additions & 2 deletions src/NautyGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ function __init__()
return
end

export
add_edge!,
rem_edge!,
add_vertex!,
add_vertices!,
rem_vertex!,
rem_vertices!,
nv, ne,
vertices, edges,
has_vertex, has_edge,
inneighbors, outneighbors,
neighbors,
is_directed,
edgetype,
Edge

export
AbstractNautyGraph,
NautyGraph,
Expand All @@ -34,8 +50,9 @@ export
iscanon,
nauty,
canonize!,
canonize,
canonical_permutation,
canonical_id,
is_isomorphic,
≃,
canonical_id
end
14 changes: 14 additions & 0 deletions src/nauty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ function canonize!(g::DenseNautyGraph)
_copycanon!(g, canong, canonperm)
return canonperm
end

"""
canonize(g::AbstractNautyGraph)

Canonize a copy of `g` and return the copy and canonical permutation.
"""
function canonize(::AbstractNautyGraph) end

function canonize(g::DenseNautyGraph)
h = copy(g)
perm = canonize!(h)
return h, perm
end

function _copycanon!(g, canong, canonperm)
copy!(g.graphset, canong)
permute!(g.labels, canonperm)
Expand Down
Loading