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

Commit

Permalink
add DummyEdgeMap and make it default
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloLucibello committed Apr 12, 2016
1 parent cec121f commit d55b136
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/LightGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ catch
end

import Base: write, ==, <, *, isless, issubset, complement, union, intersect,
reverse, reverse!, blkdiag, getindex, show, print, copy, in,
reverse, reverse!, blkdiag, getindex, setindex!, show, print, copy, in,
sum, size, sparse, eltype, length, ndims, issym, transpose,
ctranspose, join, start, next, done, eltype
ctranspose, join, start, next, done, eltype, get


# core
Expand Down
2 changes: 1 addition & 1 deletion src/traversals/bfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function traverse_graph!(
source,
visitor::SimpleGraphVisitor;
vertexcolormap = zeros(Int, nv(graph)),
edgecolormap = Dict{Edge, Int}(),
edgecolormap = DummyEdgeMap(),
queue = Vector{Int}())

for s in source
Expand Down
2 changes: 1 addition & 1 deletion src/traversals/dfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function traverse_graph!(
s::Int,
visitor::SimpleGraphVisitor;
vertexcolormap = zeros(Int, nv(graph)),
edgecolormap = Dict{Edge, Int}())
edgecolormap = DummyEdgeMap())

vertexcolormap[s] = 1
discover_vertex!(visitor, s) || return
Expand Down
9 changes: 9 additions & 0 deletions src/traversals/graphvisit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ end
# This is the common base for BreadthFirst and DepthFirst
abstract SimpleGraphVisitAlgorithm

type DummyEdgeMap
end

getindex(d::DummyEdgeMap, e::Edge) = 0
setindex!(d::DummyEdgeMap, x, e::Edge) = x
get(d::DummyEdgeMap, e::Edge, x) = x




###########################################################
#
Expand Down

0 comments on commit d55b136

Please sign in to comment.