From d55b1369e030ae8e1d07a061737cfc0b82cfdba0 Mon Sep 17 00:00:00 2001 From: CarloLucibello Date: Tue, 12 Apr 2016 09:19:34 +0200 Subject: [PATCH] add DummyEdgeMap and make it default --- src/LightGraphs.jl | 4 ++-- src/traversals/bfs.jl | 2 +- src/traversals/dfs.jl | 2 +- src/traversals/graphvisit.jl | 9 +++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/LightGraphs.jl b/src/LightGraphs.jl index 805ed8839..3e8d5c2cd 100644 --- a/src/LightGraphs.jl +++ b/src/LightGraphs.jl @@ -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 diff --git a/src/traversals/bfs.jl b/src/traversals/bfs.jl index c006a0191..9baa06faf 100644 --- a/src/traversals/bfs.jl +++ b/src/traversals/bfs.jl @@ -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 diff --git a/src/traversals/dfs.jl b/src/traversals/dfs.jl index 93f45af4e..0226b22ee 100644 --- a/src/traversals/dfs.jl +++ b/src/traversals/dfs.jl @@ -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 diff --git a/src/traversals/graphvisit.jl b/src/traversals/graphvisit.jl index 36bc16e1e..9d9efe24e 100644 --- a/src/traversals/graphvisit.jl +++ b/src/traversals/graphvisit.jl @@ -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 + + + ########################################################### #