Skip to content

Commit

Permalink
* fixed bug in sparsetocycles
Browse files Browse the repository at this point in the history
  The test is in PermutationsA
  • Loading branch information
jlapeyre committed Dec 16, 2014
1 parent 402561a commit b03248d
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/PermPlain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ function sparsetocycles{T}(sp::Dict{T,T})
break
end
end
foundunseen == false ? (push!(cycs,cyc); break) : nothing
# foundunseen == false && break
nseen = nseen + 1
foundunseen == false && break
kcyclestart = k
cyc = Array(T,0)
while true
push!(cyc,k)
if seen[k] == true
# error("double setting seen k=$k, nseen=$nseen, kcyclestart=$kcyclestart")
error("Algorithm error: double setting seen k=$k, nseen=$nseen, kcyclestart=$kcyclestart")
end
seen[k] = true
k = sp[k]
Expand All @@ -74,14 +72,6 @@ function sparsetocycles{T}(sp::Dict{T,T})
end
push!(cycs,cyc)
end
# vals = collect(values(seen))
# length(vals) != nseen && error("nseen $nseen not equal to nvals $(length(vals))")
# if ! isempty(findin(collect(values(seen)),false))
# println("uhoh")
# println("nseen $nseen not equal to nvals $(length(vals))")
# println(seen)
# error("Not all seen in sparsetocycles!")
# end
return cycs
end

Expand Down

0 comments on commit b03248d

Please sign in to comment.