Skip to content

Commit ca56f1f

Browse files
committed
Static Graphs issue #8
1 parent 52dc3ac commit ca56f1f

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/StaticGraphs.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Base:
1010
import LightGraphs:
1111
_NI, _insert_and_dedup!, AbstractEdge, AbstractEdgeIter,
1212
src, dst, edgetype, nv, ne, vertices, edges, is_directed,
13-
has_vertex, has_edge, in_neighbors, out_neighbors,
13+
has_vertex, has_edge, inneighbors, outneighbors,
1414
indegree, outdegree, degree, insorted, squash,
1515

1616
AbstractGraphFormat, loadgraph, savegraph
@@ -75,17 +75,16 @@ end
7575
nv(g::AbstractStaticGraph{T, U}) where T where U = T(length(g.f_ind) - 1)
7676
vertices(g::AbstractStaticGraph{T, U}) where T where U = one(T):nv(g)
7777

78-
7978
has_edge(g::AbstractStaticGraph, e::AbstractStaticEdge) =
80-
insorted(dst(e), out_neighbors(g, src(e)))
79+
insorted(dst(e), outneighbors(g, src(e)))
8180

8281
edgetype(g::AbstractStaticGraph{T}) where T = StaticEdge{T}
8382
edges(g::AbstractStaticGraph) = StaticEdgeIter(g)
8483

8584
has_vertex(g::AbstractStaticGraph, v::Integer) = v in vertices(g)
8685

87-
out_neighbors(g::AbstractStaticGraph, v::Integer) = fadj(g, v)
88-
in_neighbors(g::AbstractStaticGraph, v::Integer) = badj(g, v)
86+
outneighbors(g::AbstractStaticGraph, v::Integer) = fadj(g, v)
87+
inneighbors(g::AbstractStaticGraph, v::Integer) = badj(g, v)
8988

9089
zero(g::T) where T<:AbstractStaticGraph = T()
9190

@@ -97,6 +96,7 @@ include("staticgraph.jl")
9796
include("staticdigraph.jl")
9897
include("persistence.jl")
9998

99+
100100
const SGraph = StaticGraph
101101
const SDiGraph = StaticDiGraph
102102

@@ -105,5 +105,6 @@ const StaticEdgeIter{G} = LightGraphs.SimpleGraphs.SimpleEdgeIter{G}
105105
eltype(::Type{StaticEdgeIter{StaticGraph{T, U}}}) where T where U = StaticGraphEdge{T}
106106
eltype(::Type{StaticEdgeIter{StaticDiGraph{T, U}}}) where T where U = StaticDiGraphEdge{T}
107107

108+
include("overrides.jl")
108109

109110
end # module

src/overrides.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
adjacency_matrix(g::StaticGraph) = SparseMatrixCSC{Bool,UInt32}(nv(g), nv(g), g.f_ind, g.f_vec, ones(Bool, ne(g)*2))
2+
adjacency_matrix(g::StaticDiGraph) = SparseMatrixCSC{Bool,UInt32}(nv(g), nv(g), g.f_ind, g.f_vec, ones(Bool, ne(g)))

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const testdir = dirname(@__FILE__)
3030
@test @inferred eltype(hu) == UInt8
3131
@test testfn(ne)
3232
@test testfn(nv)
33-
@test testfn(in_neighbors, 1)
34-
@test testfn(out_neighbors, 1)
33+
@test testfn(inneighbors, 1)
34+
@test testfn(outneighbors, 1)
3535
@test testfn(vertices)
3636
@test testfn(degree)
3737
@test testfn(degree, 1)
@@ -73,8 +73,8 @@ const testdir = dirname(@__FILE__)
7373
@test @inferred eltype(dhu) == UInt8
7474
@test dtestfn(ne)
7575
@test dtestfn(nv)
76-
@test dtestfn(in_neighbors, 1)
77-
@test dtestfn(out_neighbors, 1)
76+
@test dtestfn(inneighbors, 1)
77+
@test dtestfn(outneighbors, 1)
7878
@test dtestfn(vertices)
7979
@test dtestfn(degree)
8080
@test dtestfn(degree, 1)

0 commit comments

Comments
 (0)