Skip to content

Commit

Permalink
Updated Graph\Frames Interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleCeresoli committed Nov 23, 2023
1 parent 10dcdab commit 25fa912
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
13 changes: 6 additions & 7 deletions src/Frames.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
66 changes: 33 additions & 33 deletions src/Graph.jl
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit 25fa912

Please sign in to comment.