Skip to content

Commit

Permalink
changed smallgraph creation to unsafe_add_edge\!() - closes JuliaAtti…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbromberger committed Oct 24, 2015
1 parent 07ea83a commit d353089
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/smallgraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function CompleteGraph(n::Integer)
g = Graph(n)
for i = 1:n, j=1:n
if i < j
add_edge!(g,i,j)
unsafe_add_edge!(g, Edge(i,j))
end
end
return g
Expand All @@ -21,7 +21,7 @@ function CompleteDiGraph(n::Integer)
g = DiGraph(n)
for i = 1:n, j=1:n
if i != j
add_edge!(g,i,j)
unsafe_add_edge!(g, Edge(i,j))
end
end
return g
Expand All @@ -33,7 +33,7 @@ with edges to each other vertex.
function StarGraph(n::Integer)
g = Graph(n)
for i = 2:n
add_edge!(g,1,i)
unsafe_add_edge!(g, Edge(1,i))
end
return g
end
Expand All @@ -44,7 +44,7 @@ vertex with directed edges to every other vertex.
function StarDiGraph(n::Integer)
g = DiGraph(n)
for i = 2:n
add_edge!(g,1,i)
unsafe_add_edge!(g, Edge(1,i))
end
return g
end
Expand All @@ -54,7 +54,7 @@ successive vertex by a single edge."""
function PathGraph(n::Integer)
g = Graph(n)
for i = 2:n
add_edge!(g, i-1, i)
unsafe_add_edge!(g, Edge(i-1, i))
end
return g
end
Expand All @@ -64,7 +64,7 @@ successive vertex by a single directed edge."""
function PathDiGraph(n::Integer)
g = DiGraph(n)
for i = 2:n
add_edge!(g, i-1, i)
unsafe_add_edge!(g, Edge(i-1, i))
end
return g
end
Expand All @@ -75,10 +75,10 @@ the outer vertices connected via a closed path graph.
function WheelGraph(n::Integer)
g = StarGraph(n)
for i = 3:n
add_edge!(g, i-1, i)
unsafe_add_edge!(g, Edge(i-1, i))
end
if n != 2
add_edge!(g, n,2)
unsafe_add_edge!(g, Edge(n, 2))
end
return g
end
Expand All @@ -89,10 +89,10 @@ with the outer vertices connected via a closed path graph.
function WheelDiGraph(n::Integer)
g = StarDiGraph(n)
for i = 3:n
add_edge!(g, i-1, i)
unsafe_add_edge!(g, Edge(i-1, i))
end
if n != 2
add_edge!(g, n,2)
unsafe_add_edge!(g, Edge(n, 2))
end
return g
end
Expand All @@ -101,15 +101,15 @@ end
function _make_simple_undirected_graph{T<:Integer}(n::T, edgelist::Vector{@compat(Tuple{T,T})})
g = Graph(n)
for (s,d) in edgelist
add_edge!(g,s,d)
unsafe_add_edge!(g, Edge(s,d))
end
return g
end

function _make_simple_directed_graph{T<:Integer}(n::T, edgelist::Vector{@compat(Tuple{T,T})})
g = DiGraph(n)
for (s,d) in edgelist
add_edge!(g,s,d)
unsafe_add_edge!(g, Edge(s,d))
end
return g
end
Expand Down Expand Up @@ -250,8 +250,8 @@ end
"""A house graph, with two edges crossing the bottom square."""
function HouseXGraph()
g = HouseGraph()
add_edge!(g, 1, 4)
add_edge!(g, 2, 3)
unsafe_add_edge!(g, Edge(1, 4))
unsafe_add_edge!(g, Edge(2, 3))
return g
end

Expand Down

0 comments on commit d353089

Please sign in to comment.