Skip to content

Commit

Permalink
Name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
scheinerman committed Jul 17, 2022
1 parent 5180781 commit 2cfa5d6
Show file tree
Hide file tree
Showing 39 changed files with 274 additions and 272 deletions.
2 changes: 1 addition & 1 deletion src/SimpleGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ include("embedding/embedding.jl")

include("hyper/SimpleHypergraphs.jl")

include("abbreviations.jl")
# include("abbreviations.jl")

end # module SimpleGraphs
10 changes: 3 additions & 7 deletions src/abbreviations.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const UG = SimpleGraph
const DG = SimpleDigraph
# const HG = SimpleHypergraph
export UG, DG



# These names will not be necessary in versions 0.8.1 and on

const UndirectedGraph = SimpleGraph
const DirectedGraph = SimpleDigraph
const DirectedGraph = DirectedGraph
const HyperGraph = HyperGraph

export UndirectedGraph, DirectedGraph, HyperGraph
export DirectedGraph, HyperGraph
4 changes: 2 additions & 2 deletions src/bisect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This can be invoked as follows:
A plain call to `bisect(G)` is equivalent to `bisect(G,"zero")` (which
is the same as `bisect(G,"user", 0.0)`).
"""
function bisect(G::SimpleGraph, where::AbstractString = "zero", pivot::Real = 0.0)
function bisect(G::UndirectedGraph, where::AbstractString = "zero", pivot::Real = 0.0)

verbose = false

Expand Down Expand Up @@ -100,7 +100,7 @@ end
one end in `A` and one end in `B`. Here `A` and `B` are collections
of vertices of `G`.
"""
function cross_edges(G::SimpleGraph, A, B)
function cross_edges(G::UndirectedGraph, A, B)

AB = Base.Iterators.product(A, B)

Expand Down
14 changes: 7 additions & 7 deletions src/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ export cache_clear, cache_on, cache_off, cache_recall, cache_check, cache_save
`cache_clear(G,item)` clears just that item.
"""
function cache_clear(G::SimpleGraph)
function cache_clear(G::UndirectedGraph)
if length(G.cache) > 0
G.cache = Dict{Symbol,Any}()
end
nothing
end

cache_clear(G::SimpleGraph, item::Symbol) = delete!(G.cache, item)
cache_clear(G::UndirectedGraph, item::Symbol) = delete!(G.cache, item)

"""
`cache_check(G,item)` checks if the symbol `item` is a valid key.
"""
cache_check(G::SimpleGraph, item::Symbol)::Bool = G.cache_flag && haskey(G.cache, item)
cache_check(G::UndirectedGraph, item::Symbol)::Bool = G.cache_flag && haskey(G.cache, item)

"""
`cache_recall(G,item)` retreives the value associated with `item`.
**WARNING**: No check is done to see if this value is defined. Be
sure to use `cache_check` first!
"""
cache_recall(G::SimpleGraph, item::Symbol) = G.cache[item]
cache_recall(G::UndirectedGraph, item::Symbol) = G.cache[item]



"""
`cache_save(G,item,value)` saves `value` associated with
the symbol (key) `item` in the cache for this graph.
"""
function cache_save(G::SimpleGraph, item::Symbol, value)
function cache_save(G::UndirectedGraph, item::Symbol, value)
if G.cache_flag
G.cache[item] = value
end
Expand All @@ -51,14 +51,14 @@ end
"""
`cache_on(G)` activates results caching for this graph. See also: `cache_off`.
"""
cache_on(G::SimpleGraph) = G.cache_flag = true
cache_on(G::UndirectedGraph) = G.cache_flag = true

"""
`cache_off(G)` deactivates cache checking. You may also wish to call
`cache_clear` to recover storage.
See also: `cache_on`.
"""
function cache_off(G::SimpleGraph)
function cache_off(G::UndirectedGraph)
G.cache_flag = false
end
4 changes: 2 additions & 2 deletions src/d_dist.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function dist_matrix(G::SimpleDigraph)
function dist_matrix(G::DirectedGraph)
VV = vlist(G)
n = length(VV)
A = zeros(Int, n, n)
Expand All @@ -12,7 +12,7 @@ function dist_matrix(G::SimpleDigraph)
return A
end

function diam(G::SimpleDigraph)
function diam(G::DirectedGraph)
A = dist_matrix(G)
if minimum(A) < 0
return -1
Expand Down
10 changes: 5 additions & 5 deletions src/d_euler.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export euler, is_cut_edge

function euler(G::SimpleDigraph{T}, u::T, v::T) where {T}
function euler(G::DirectedGraph{T}, u::T, v::T) where {T}
notrail = T[]
#check in_degrees and out_degrees of start and end vertex first
if u == v
Expand All @@ -25,12 +25,12 @@ function euler(G::SimpleDigraph{T}, u::T, v::T) where {T}
return euler_work!(GG, u)
end

euler(G::SimpleDigraph, u) = euler(G, u, u)
euler(G::SimpleDigraph) = euler(G, first(G.V))
euler(G::DirectedGraph, u) = euler(G, u, u)
euler(G::DirectedGraph) = euler(G, first(G.V))


# determine if an edge in a directed graph is a cut edge
function is_cut_edge(G::SimpleDigraph{T}, u::T, v::T) where {T}
function is_cut_edge(G::DirectedGraph{T}, u::T, v::T) where {T}
if !has(G, u, v)
error("No such edge in this graph")
end
Expand All @@ -48,7 +48,7 @@ end

# helper function to determine if there is euler path
# function euler_work!(G::SimpleDigraph{T}, u::T) where {T}
function euler_work!(G::SimpleDigraph{T}, u::T) where {T}
function euler_work!(G::DirectedGraph{T}, u::T) where {T}
trail = T[]
while true
Nu = out_neighbors(G, u)
Expand Down
8 changes: 4 additions & 4 deletions src/d_ham.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export hamiltonian_cycle

#check if it is safe to add vertex v to the path
function isSafe(v::T, G::SimpleDigraph{T}, path::Deque{T}) where {T}
function isSafe(v::T, G::DirectedGraph{T}, path::Deque{T}) where {T}
prev = last(path)

#check if the added vertex is an out_neighbor of the previous vertex
Expand All @@ -21,7 +21,7 @@ function isSafe(v::T, G::SimpleDigraph{T}, path::Deque{T}) where {T}
return true
end

function hamCycle(G::SimpleDigraph{T}, path::Deque{T}) where {T}
function hamCycle(G::DirectedGraph{T}, path::Deque{T}) where {T}
#if all vertices are included in the cycle
if length(path) == NV(G)
#check if last vertex is connected to first vertex in path
Expand Down Expand Up @@ -49,7 +49,7 @@ function hamCycle(G::SimpleDigraph{T}, path::Deque{T}) where {T}
end

#check if a directed graph contains a hamiltonian cycle
function directed_ham_cycle(G::SimpleDigraph{T}) where {T}
function directed_ham_cycle(G::DirectedGraph{T}) where {T}
result = Deque{T}()
vlist = collect(G.V)

Expand All @@ -72,6 +72,6 @@ function directed_ham_cycle(G::SimpleDigraph{T}) where {T}
end

#export the result as an array
function hamiltonian_cycle(G::SimpleDigraph{T}) where {T}
function hamiltonian_cycle(G::DirectedGraph{T}) where {T}
return collect(directed_ham_cycle(G))
end
4 changes: 2 additions & 2 deletions src/d_simple_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function ShiftDigraph(alphabet = [0, 1], n::Int = 3)
vertex_iter = all_tuples(alphabet, n)
vlist = collect(vertex_iter)
T = typeof(vlist[1])
G = SimpleDigraph{T}()
G = DirectedGraph{T}()
for v in vlist
add!(G, v)
end
Expand All @@ -143,7 +143,7 @@ function for creating a Torus Graph
function TorusDigraph(n::Int = 4, m::Int = 3)

T = Tuple{Int,Int}
G = SimpleDigraph{T}()
G = DirectedGraph{T}()

#create vertices
vlist = Tuple{Int,Int}[]
Expand Down
Loading

0 comments on commit 2cfa5d6

Please sign in to comment.