-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "FactorGraphs" | ||
uuid = "edf0a622-c16b-410a-a162-e53dc16a76ae" | ||
authors = ["stecrotti <[email protected]>"] | ||
version = "1.0.0-DEV" | ||
version = "0.1.0" | ||
|
||
[deps] | ||
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
""" | ||
InfinteRegularFactorGraph <: AbstractFactorGraph | ||
InfiniteRegularFactorGraph <: AbstractFactorGraph | ||
A type to represent an infinite regular factor graph with fixed factor and variable degree | ||
""" | ||
struct InfinteRegularFactorGraph{T<:Integer} <: AbstractFactorGraph{T} | ||
struct InfiniteRegularFactorGraph{T<:Integer} <: AbstractFactorGraph{T} | ||
kᵢ :: T # variable degree | ||
kₐ :: T # factor degree | ||
|
||
function InfinteRegularFactorGraph(kₐ::T, kᵢ::T) where {T<:Integer} | ||
function InfiniteRegularFactorGraph(kₐ::T, kᵢ::T) where {T<:Integer} | ||
kᵢ > 0 || throw(ArgumentError("Factor degree must be positive, got $kᵢ")) | ||
kₐ > 0 || throw(ArgumentError("Factor degree must be positive, got $kₐ")) | ||
return new{T}(kᵢ, kₐ) | ||
end | ||
end | ||
|
||
function Base.show(io::IO, g::InfinteRegularFactorGraph{T}) where T | ||
println(io, "InfinteRegularFactorGraph{$T} of variable degree $(g.kᵢ) and factor degree $(g.kₐ)") | ||
function Base.show(io::IO, g::InfiniteRegularFactorGraph{T}) where T | ||
println(io, "InfiniteRegularFactorGraph{$T} of variable degree $(g.kᵢ) and factor degree $(g.kₐ)") | ||
end | ||
|
||
nvariables(::InfinteRegularFactorGraph) = 1 | ||
nfactors(::InfinteRegularFactorGraph) = 1 | ||
Graphs.ne(::InfinteRegularFactorGraph) = 1 | ||
Graphs.edges(::InfinteRegularFactorGraph) = (IndexedEdge(1,1,1) for _ in 1:1) | ||
variables(::InfinteRegularFactorGraph) = 1:1 | ||
factors(::InfinteRegularFactorGraph) = 1:1 | ||
nvariables(::InfiniteRegularFactorGraph) = 1 | ||
nfactors(::InfiniteRegularFactorGraph) = 1 | ||
Graphs.ne(::InfiniteRegularFactorGraph) = 1 | ||
Graphs.edges(::InfiniteRegularFactorGraph) = (IndexedEdge(1,1,1) for _ in 1:1) | ||
variables(::InfiniteRegularFactorGraph) = 1:1 | ||
factors(::InfiniteRegularFactorGraph) = 1:1 | ||
|
||
IndexedGraphs.degree(g::InfinteRegularFactorGraph, v::FactorGraphVertex) = length(neighbors(g, v)) | ||
IndexedGraphs.degree(g::InfiniteRegularFactorGraph, v::FactorGraphVertex) = length(neighbors(g, v)) | ||
|
||
function IndexedGraphs.neighbors(g::InfinteRegularFactorGraph, ::FactorGraphVertex{Factor}) | ||
function IndexedGraphs.neighbors(g::InfiniteRegularFactorGraph, ::FactorGraphVertex{Factor}) | ||
return Fill(1, g.kₐ) | ||
end | ||
function IndexedGraphs.neighbors(g::InfinteRegularFactorGraph, ::FactorGraphVertex{Variable}) | ||
function IndexedGraphs.neighbors(g::InfiniteRegularFactorGraph, ::FactorGraphVertex{Variable}) | ||
return Fill(1, g.kᵢ) | ||
end | ||
edge_indices(g::InfinteRegularFactorGraph, ::FactorGraphVertex{Factor}) = Fill(1, g.kₐ) | ||
edge_indices(g::InfinteRegularFactorGraph, ::FactorGraphVertex{Variable}) = Fill(1, g.kᵢ) | ||
edge_indices(g::InfiniteRegularFactorGraph, ::FactorGraphVertex{Factor}) = Fill(1, g.kₐ) | ||
edge_indices(g::InfiniteRegularFactorGraph, ::FactorGraphVertex{Variable}) = Fill(1, g.kᵢ) |