Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #216 from wkearn/adjlist
Browse files Browse the repository at this point in the history
Construct an empty adjlist when called with a vector
  • Loading branch information
papamarkou committed May 29, 2016
2 parents 10db176 + e7d8502 commit 63be068
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/adjacency_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typealias AdjacencyList{V} GenericAdjacencyList{V, Vector{V}, Vector{Vector{V}}}

simple_adjlist(nv::Int; is_directed::Bool=true) = SimpleAdjacencyList(is_directed, 1:nv, 0, multivecs(Int, nv))

adjlist{V}(vs::Vector{V}; is_directed::Bool=true) = AdjacencyList{V}(is_directed, vs, 0, Vector{V}[])
adjlist{V}(vs::Vector{V}; is_directed::Bool=true) = AdjacencyList{V}(is_directed, vs, 0, multivecs(V,length(vs)))
adjlist{V}(::Type{V}; is_directed::Bool=true) = adjlist(V[]; is_directed=is_directed)

## required interfaces
Expand Down
3 changes: 3 additions & 0 deletions test/adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ for g in [adjlist(KeyVertex{ASCIIString}), adjlist(ASCIIString)]

end

g = adjlist(collect(1:10),is_directed=false)
add_edge!(g,1,2)

# # construct via adjacency matrix
# A = [true true true; false false true; false false true]
# g = simple_adjlist(A)
Expand Down

0 comments on commit 63be068

Please sign in to comment.