diff --git a/Project.toml b/Project.toml index b521f0c..9fd15fc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JSMDInterfaces" uuid = "6b30ee2f-618e-4a15-bf4e-7df7b496e609" authors = ["JSMD Team"] -version = "1.4.0" +version = "1.4.1" [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" diff --git a/src/Frames.jl b/src/Frames.jl index cfe763b..cbd76af 100644 --- a/src/Frames.jl +++ b/src/Frames.jl @@ -1,22 +1,21 @@ module Frames -using Graphs: AbstractGraph -using JSMDInterfaces.Interface - export AbstractJSMDFrameGraph, vector3, vector6, vector9, vector12, rotation3, rotation6, rotation9, rotation12 +using JSMDInterfaces.Interface + +import JSMDInterfaces.Graph: AbstractJSMDGraph + + """ AbstractJSMDFrameGraph Abstract type for frames graphs. Subtype it to create a new frames graph compatible with the ecosystem. """ -abstract type AbstractJSMDFrameGraph{T} <: AbstractGraph{T} end - -# ---- -# JSMD interface +abstract type AbstractJSMDFrameGraph{T} <: AbstractJSMDGraph{T} end """ vector3(model::F, from::Int, to::Int, axis::Int, time::Number) diff --git a/src/Graph.jl b/src/Graph.jl index e4c5c5e..87d6861 100644 --- a/src/Graph.jl +++ b/src/Graph.jl @@ -1,44 +1,33 @@ module Graph using JSMDInterfaces.Interface -using Graphs -using JSMDInterfaces.Interface: @interface - -import Graphs: has_vertex, - has_edge, - edges, - edgetype, - inneighbors, - ne, - nv, - outneighbors, - vertices, - is_directed +import Graphs """ AbstractJSMDGraph{T} Abstract type for graphs. -Subtype it to create a graphs compatible with the ecosystem. - -Graphs here could be compatible with both JSMD ecosystem and [`Graphs.jl`](https://github.com/JuliaGraphs/Graphs.jl). - -For `JSMD` compatibility, see also: [`add_vertex!`](@ref) and [`add_edge!`](@ref). +Subtype it to create graphs compatible with the JSMD ecosystem. -For `Graphs.jl` compatibility, see also: [Graphs.jl interface](https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/) +Graphs here could be compatible with both JSMD ecosystem and [`Graphs.jl`](https://github.com/JuliaGraphs/Graphs.jl): + - For `JSMD` compatibility, see also: [`has_path`](@ref) and [`get_path`](@ref). + - For `Graphs.jl` compatibility, see also: [Graphs.jl interface](https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/) """ -abstract type AbstractJSMDGraph{T} <: AbstractGraph{T} end +abstract type AbstractJSMDGraph{T} <: Graphs.AbstractGraph{T} end + """ AbstractJSMDGraphNode Abstract type for graph nodes. -Subtype it to create a graph nodes compatible with the ecosystem. +Subtype it to create a node graph compatible with the JSMD ecosystem. """ abstract type AbstractJSMDGraphNode end -# Graphs interface + +# Graphs interfaces +# ================== @interface function Graphs.has_vertex(::AbstractJSMDGraph, ::Int) end @@ -60,26 +49,37 @@ abstract type AbstractJSMDGraphNode end @interface function Graphs.is_directed(::AbstractJSMDGraph) end -# JSMD interface + +# JSMD interfaces +# ================== """ - add_vertex!(::AbstractJSMDGraph, ::N) + add_vertex!(g::AbstractJSMDGraph, vertex::AbstractJSMDGraphNode) -This function serves as an interface for inserting a new vertex in a graph. +This function adds `vertex` to the graph `g`. +""" +@interface function Graphs.add_vertex!(::AbstractJSMDGraph, ::N) where {N<:AbstractJSMDGraphNode} end + +""" + add_edge!(g::AbstractJSMDGraph, from::Int, to::Int, cost::Int) -!!! warning - Concrete implementations of `AbstractJSMDGraph` must provide this function! +This function add an edge between `from` and `to` with weight `cost`. """ -@interface function add_vertex!(::AbstractJSMDGraph, ::N) where {N<:AbstractJSMDGraphNode} end +@interface function Graphs.add_edge!(::AbstractJSMDGraph, ::Int, ::Int, ::Int) end """ - add_edge!(::AbstractJSMDGraph, ::Int, ::Int, ::Int) + has_path(g::AbstractJSMDGraph, from::Int, to::Int) -This function serves as an interface for inserting a new (weighted) edge in a graph. +Return true if there is a path between `from` and `to` in the graph `g`. +""" +@interface function has_path(::AbstractJSMDGraph, ::Int, ::Int) end + +""" + get_path(g::AbstractJSMDGraph, from::Int, to::Int) -!!! warning - Concrete implementations of `AbstractJSMDGraph` must provide this function! +Get the nodes on hte path between and including `from' and `to`. Returns an empty array if +either `from` or `to` are not part of `g` or if there is no path between them. """ -@interface function add_edge!(::AbstractJSMDGraph, ::Int, ::Int, ::Int) end +@interface function get_path(::AbstractJSMDGraph, ::Int, ::Int) end end \ No newline at end of file