diff --git a/README.md b/README.md index 054d0a3..cb73637 100644 --- a/README.md +++ b/README.md @@ -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; diff --git a/docs/make.jl b/docs/make.jl index ec24017..8aa8e1a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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 = [ diff --git a/docs/src/graph_creation.md b/docs/src/graph_creation.md index e6cdaa5..cd4e0ad 100644 --- a/docs/src/graph_creation.md +++ b/docs/src/graph_creation.md @@ -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; diff --git a/docs/src/index.md b/docs/src/index.md index d1b2b49..e6e51e3 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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; diff --git a/docs/src/isomorphism.md b/docs/src/isomorphism.md index 0b1cf08..f12ad59 100644 --- a/docs/src/isomorphism.md +++ b/docs/src/isomorphism.md @@ -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 diff --git a/src/NautyGraphs.jl b/src/NautyGraphs.jl index f27a804..78f2b30 100644 --- a/src/NautyGraphs.jl +++ b/src/NautyGraphs.jl @@ -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, @@ -34,8 +50,9 @@ export iscanon, nauty, canonize!, + canonize, canonical_permutation, + canonical_id, is_isomorphic, - ≃, - canonical_id + ≃ end diff --git a/src/nauty.jl b/src/nauty.jl index 502d3b0..87ac206 100644 --- a/src/nauty.jl +++ b/src/nauty.jl @@ -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)