Skip to content

Commit 000c642

Browse files
committed
LightGraphs to Graphs
1 parent 22f8089 commit 000c642

12 files changed

+45
-47
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
1010
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1111
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
1212
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
13-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
13+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1616
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -24,10 +24,10 @@ Compat = "2.2, 3"
2424
DataStructures = "0.17, 0.18"
2525
FiniteDiff = "2.8.1"
2626
ForwardDiff = "0.10"
27-
LightGraphs = "1.3"
27+
Graphs = "1.4"
2828
Requires = "0.5, 1.0"
2929
StaticArrays = "1"
30-
VertexSafeGraphs = "0.1"
30+
VertexSafeGraphs = "0.2"
3131
julia = "1.6"
3232

3333
[extras]

src/SparseDiffTools.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module SparseDiffTools
33
using Compat
44
using FiniteDiff
55
using ForwardDiff
6-
using LightGraphs
7-
using LightGraphs: SimpleGraph
6+
using Graphs
7+
using Graphs: SimpleGraph
88
using Requires
99
using VertexSafeGraphs
1010
using Adapt

src/coloring/acyclic_coloring.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
color_graph(g::LightGraphs.AbstractGraphs, ::AcyclicColoring)
2+
color_graph(g::Graphs.AbstractGraphs, ::AcyclicColoring)
33
44
Returns a coloring vector following the acyclic coloring rules (1) the coloring
55
corresponds to a distance-1 coloring, and (2) vertices in every cycle of the
@@ -9,7 +9,7 @@ is a collection of trees—and hence is acyclic.
99
1010
Reference: Gebremedhin AH, Manne F, Pothen A. **New Acyclic and Star Coloring Algorithms with Application to Computing Hessians**
1111
"""
12-
function color_graph(g::LightGraphs.AbstractGraph, ::AcyclicColoring)
12+
function color_graph(g::Graphs.AbstractGraph, ::AcyclicColoring)
1313
color = zeros(Int, nv(g))
1414
two_colored_forest = DisjointSets{Int}(())
1515

@@ -67,7 +67,7 @@ end
6767
v::Integer,
6868
w::Integer,
6969
x::Integer,
70-
g::LightGraphs.AbstractGraph,
70+
g::Graphs.AbstractGraph,
7171
two_colored_forest::DisjointSets{<:Integer},
7272
color::AbstractVector{<:Integer})
7373
@@ -81,7 +81,7 @@ function prevent_cycle!(first_visit_to_tree::AbstractVector{<:Tuple{Integer,Inte
8181
v::Integer,
8282
w::Integer,
8383
x::Integer,
84-
g::LightGraphs.AbstractGraph,
84+
g::Graphs.AbstractGraph,
8585
two_colored_forest::DisjointSets{<:Integer},
8686
color::AbstractVector{<:Integer})
8787
e = find(w, x, g, two_colored_forest)
@@ -100,7 +100,7 @@ end
100100
first_neighbor::AbstractVector{<: Tuple{Integer,Integer}},
101101
v::Integer,
102102
w::Integer,
103-
g::LightGraphs.AbstractGraph,
103+
g::Graphs.AbstractGraph,
104104
color::AbstractVector{<:Integer})
105105
106106
Grow a 2-colored star after assigning a new color to the
@@ -112,7 +112,7 @@ function grow_star!(two_colored_forest::DisjointSets{<:Integer},
112112
first_neighbor::AbstractVector{<: Tuple{Integer,Integer}},
113113
v::Integer,
114114
w::Integer,
115-
g::LightGraphs.AbstractGraph,
115+
g::Graphs.AbstractGraph,
116116
color::AbstractVector{<:Integer})
117117
insert_new_tree!(two_colored_forest,v,w,g)
118118
p, q = first_neighbor[color[w]]
@@ -132,7 +132,7 @@ end
132132
v::Integer,
133133
w::Integer,
134134
x::Integer,
135-
g::LightGraphs.AbstractGraph)
135+
g::Graphs.AbstractGraph)
136136
137137
Subroutine to merge trees present in the disjoint set which have a
138138
common edge.
@@ -141,7 +141,7 @@ function merge_trees!(two_colored_forest::DisjointSets{<:Integer},
141141
v::Integer,
142142
w::Integer,
143143
x::Integer,
144-
g::LightGraphs.AbstractGraph)
144+
g::Graphs.AbstractGraph)
145145
e1 = find(v,w,g,two_colored_forest)
146146
e2 = find(w,x,g,two_colored_forest)
147147
if e1 != e2
@@ -154,15 +154,15 @@ end
154154
insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
155155
v::Integer,
156156
w::Integer,
157-
g::LightGraphs.AbstractGraph)
157+
g::Graphs.AbstractGraph)
158158
159159
creates a new singleton set in the disjoint set 'two_colored_forest' consisting
160160
of the edge connecting v and w in the graph g
161161
"""
162162
function insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
163163
v::Integer,
164164
w::Integer,
165-
g::LightGraphs.AbstractGraph)
165+
g::Graphs.AbstractGraph)
166166
edge_index = find_edge_index(v,w,g)
167167
push!(two_colored_forest,edge_index)
168168
end
@@ -181,28 +181,28 @@ end
181181
"""
182182
find(w::Integer,
183183
x::Integer,
184-
g::LightGraphs.AbstractGraph,
184+
g::Graphs.AbstractGraph,
185185
two_colored_forest::DisjointSets{<:Integer})
186186
187187
Returns the root of the disjoint set to which the edge connecting vertices w and x
188188
in the graph g belongs to
189189
"""
190190
function find(w::Integer,
191191
x::Integer,
192-
g::LightGraphs.AbstractGraph,
192+
g::Graphs.AbstractGraph,
193193
two_colored_forest::DisjointSets{<:Integer})
194194
edge_index = find_edge_index(w, x, g)
195195
return find_root!(two_colored_forest, edge_index)
196196
end
197197

198198

199199
"""
200-
find_edge(g::LightGraphs.AbstractGraph, v::Integer, w::Integer)
200+
find_edge(g::Graphs.AbstractGraph, v::Integer, w::Integer)
201201
202202
Returns an integer equivalent to the index of the edge connecting the vertices
203203
v and w in the graph g
204204
"""
205-
function find_edge_index(v::Integer, w::Integer, g::LightGraphs.AbstractGraph)
205+
function find_edge_index(v::Integer, w::Integer, g::Graphs.AbstractGraph)
206206
pos = 1
207207
for i in edges(g)
208208

src/coloring/backtracking_coloring.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""
2-
color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
2+
color_graph(g::Graphs.AbstractGraph, ::BacktrackingColor)
33
44
Return a tight, distance-1 coloring of graph g
55
using the minimum number of colors possible (i.e.
66
the chromatic number of graph, `χ(g)`)
77
"""
8-
function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
8+
function color_graph(g::Graphs.AbstractGraph, ::BacktrackingColor)
99
v = nv(g)
1010

1111
#A is list of vertices in non-increasing order of degree
@@ -96,14 +96,14 @@ function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
9696
end
9797

9898
"""
99-
sort_by_degree(g::LightGraphs.AbstractGraph)
99+
sort_by_degree(g::Graphs.AbstractGraph)
100100
101101
Returns a list of the vertices of graph g sorted
102102
in non-increasing order of their degrees
103103
"""
104-
function sort_by_degree(g::LightGraphs.AbstractGraph)
104+
function sort_by_degree(g::Graphs.AbstractGraph)
105105
vs = vertices(g)
106-
degrees = (LightGraphs.degree(g, v) for v in vs)
106+
degrees = (Graphs.degree(g, v) for v in vs)
107107
vertex_pairs = collect(zip(vs, degrees))
108108
sort!(vertex_pairs, by = p -> p[2], rev = true)
109109
return [v[1] for v in vertex_pairs]
@@ -129,7 +129,7 @@ end
129129
A::AbstractVector{<:Integer},
130130
colors::AbstractVector{<:Integer},
131131
F::Array{Integer,1},
132-
g::LightGraphs.AbstractGraph,
132+
g::Graphs.AbstractGraph,
133133
opt::Integer)
134134
135135
Returns set of free colors of x which are less
@@ -149,7 +149,7 @@ function free_colors(x::Integer,
149149
A::AbstractVector{<:Integer},
150150
colors::AbstractVector{<:Integer},
151151
F::Array{Integer,1},
152-
g::LightGraphs.AbstractGraph,
152+
g::Graphs.AbstractGraph,
153153
opt::Integer)
154154
index = -1
155155

src/coloring/greedy_star1_coloring.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ colors.
2121
2222
Reference: Gebremedhin AH, Manne F, Pothen A. **What color is your Jacobian? Graph coloring for computing derivatives.** SIAM review. 2005;47(4):629-705.
2323
"""
24-
function color_graph(g::LightGraphs.AbstractGraph, ::GreedyStar1Color)
24+
function color_graph(g::Graphs.AbstractGraph, ::GreedyStar1Color)
2525
v = nv(g)
2626
colorvec = zeros(Int, v)
2727

src/coloring/greedy_star2_coloring.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Reference: Gebremedhin AH, Manne F, Pothen A. **What color is your Jacobian? Gra
2323
2424
TODO: add text explaining the difference between star1 and star2
2525
"""
26-
function color_graph(g::LightGraphs.AbstractGraph, ::GreedyStar2Color)
26+
function color_graph(g::Graphs.AbstractGraph, ::GreedyStar2Color)
2727
v = nv(g)
2828
colorvec = zeros(Int, v)
2929

test/test_acyclic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using SparseDiffTools
2-
using LightGraphs
3-
using LightGraphs: SimpleGraph
2+
using Graphs
3+
using Graphs: SimpleGraph
44
using Test
55

66
using Random

test/test_bsc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using SparseDiffTools
2-
using LightGraphs
3-
using LightGraphs: SimpleGraph
2+
using Graphs
3+
using Graphs: SimpleGraph
44
using Random
55
#=
66
Graph g0

test/test_contraction.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using SparseDiffTools
22
using VertexSafeGraphs
3-
using LightGraphs
4-
using LightGraphs: SimpleGraph
3+
using Graphs
4+
using Graphs: SimpleGraph
55

66
using Random
77
Random.seed!(123)

test/test_greedy_d1.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using SparseDiffTools
22
using VertexSafeGraphs
3-
using LightGraphs
4-
using LightGraphs: SimpleGraph
3+
using Graphs
4+
using Graphs: SimpleGraph
55
using Test
66

77
using Random

0 commit comments

Comments
 (0)