Skip to content

Commit 4d626e3

Browse files
committed
Started with the basics, add, rem, list working
TODO Connectivity tests
1 parent 32b8d6e commit 4d626e3

File tree

7 files changed

+662
-3
lines changed

7 files changed

+662
-3
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
99
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1010
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1111
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
12+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1213
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
14+
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
1315
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1416
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1517
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ include("GraphsDFG/GraphsDFG.jl")
4444
# Include the FilesDFG API.
4545
include("FileDFG/FileDFG.jl")
4646

47+
# Include the LightGraphs.jl (MetaGraphs.jl) API.
48+
include("LightGraphsDFG/LightGraphsDFG.jl")
49+
4750
export saveDFG, loadDFG
4851

4952
function __init__()

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ List the DFGVariables in the DFG.
224224
Optionally specify a label regular expression to retrieves a subset of the variables.
225225
"""
226226
function getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
227-
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, vertices(dfg.g)))
227+
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, Graphs.vertices(dfg.g)))
228228
if regexFilter != nothing
229229
variables = filter(v -> occursin(regexFilter, String(v.label)), variables)
230230
end
@@ -269,7 +269,7 @@ List the DFGFactors in the DFG.
269269
Optionally specify a label regular expression to retrieves a subset of the factors.
270270
"""
271271
function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
272-
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
272+
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, Graphs.vertices(dfg.g)))
273273
if regexFilter != nothing
274274
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
275275
end

src/LightGraphsDFG/LightGraphsDFG.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using LightGraphs
2+
using MetaGraphs
3+
4+
# Imports
5+
include("entities/LightGraphsDFG.jl")
6+
# include("services/LightGraphsDFG.jl")
7+
8+
# Exports
9+
export LightGraphsDFG
10+
# export exists
11+
# export getLabelDict, getDescription, setDescription, getInnerGraph, getAddHistory, getSolverParams, setSolverParams
12+
#
13+
# export getAddHistory, getDescription, getLabelDict
14+
# export addVariable!, addFactor!
15+
# export ls, lsf, getVariables, getFactors, getVariableIds, getFactorIds
16+
# export getVariable, getFactor
17+
# export updateVariable!, updateFactor!
18+
# export deleteVariable!, deleteFactor!
19+
# export getAdjacencyMatrix
20+
# export getAdjacencyMatrixDataFrame
21+
# export getNeighbors
22+
# export getSubgraphAroundNode
23+
# export getSubgraph
24+
# export isFullyConnected, hasOrphans
25+
# export toDot, toDotFile
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Starting of with Graph.jl implementation. There are a lot of overlap with metagraphs and some data can be moved there.
2+
"""
3+
$(TYPEDEF)
4+
Encapsulation structure for a DFGNode (Variable or Factor) in LightGraphs.jl graph.
5+
"""
6+
mutable struct LightGraphsNode
7+
index::Int
8+
dfgNode::DFGNode
9+
end
10+
11+
const LFGType = MetaGraph{Int64,Float64}
12+
13+
mutable struct LightGraphsDFG{T <: AbstractParams} <: AbstractDFG
14+
g::LFGType
15+
description::String
16+
userId::String
17+
robotId::String
18+
sessionId::String
19+
#TODO Remove nodeCounter
20+
nodeCounter::Int64 #TODO pos 'n paar van die veranderlikes dalk aan na MetaGraphs calls
21+
#TODO verander na label vector of gebruik matagrapsh sin
22+
labelDict::Dict{Symbol, Int64}
23+
addHistory::Vector{Symbol} #TODO: Discuss more - is this an audit trail?
24+
solverParams::T # Solver parameters
25+
end
26+
27+
#TODO? do we not want props such as userId, robotId, sessionId, etc...
28+
function LightGraphsDFG{T}(g::LFGType=MetaGraph(),
29+
d::String="LightGraphs.jl implementation",
30+
userId::String="User ID",
31+
robotId::String="Robot ID",
32+
sessionId::String="Session ID",
33+
n::Int64=0,
34+
l::Dict{Symbol, Int64}=Dict{Symbol, Int64}(),
35+
a::Vector{Symbol}=Symbol[];
36+
params::T=NoSolverParams()) where T <: AbstractParams
37+
set_prop!(g, :description, d)
38+
set_prop!(g, :userId, userId)
39+
set_prop!(g, :robotId, robotId)
40+
set_prop!(g, :sessionId, sessionId)
41+
set_indexing_prop!(g, :label)
42+
LightGraphsDFG{T}(g, d, userId, robotId, sessionId, n, l, a, params)
43+
end

0 commit comments

Comments
 (0)