algorithm-archive icon indicating copy to clipboard operation
algorithm-archive copied to clipboard

Update Julia Jarvis March to use points from Graham Scan

Open berquist opened this issue 5 years ago • 7 comments

This uses the points from https://github.com/algorithm-archivists/algorithm-archive/blob/4313e7eb3d2faa152590c631d180d06a5c85f46d/contents/graham_scan/code/julia/graham.jl#L50

It revealed a bug in this implementation that needs to be fixed.

berquist avatar May 24 '20 17:05 berquist

Could you elaborate on the bug a bit?

leios avatar May 24 '20 19:05 leios

Sure. The output from the Python code is

(-14, -14)
(15, -9)
(9, 9)
(0, 14)
(-6, 15)
(-10, 11)

but, from the same initial points, the Julia output is

Pos[Pos(-14.0, -14.0), Pos(15.0, -9.0), Pos(-6.0, 15.0), Pos(-14.0, -14.0)]

I haven't bothered to debug this. If someone sees the obvious fix, feel free to modify this PR or issue a new one.

berquist avatar May 24 '20 20:05 berquist

So I was looking at this today. There is definitely a bug in some implementations, but it is unclear what that is because the python code is radically different. We can rewrite the julia code to match the python code, but right now we probably need a better way of defining all the points to find the convex hull.

I really need to revise these chapters anyway, so I'll bump that up on the list.

I feel like we had this discussion somewhere on github before, but I can't find it. Sorry!

leios avatar Jun 23 '20 21:06 leios

The discussion was in https://github.com/algorithm-archivists/algorithm-archive/pull/708#issuecomment-633322788. What solution do you think is better, that one, or this hard-coded set? The points inside or on a circle from a square grid makes more sense to me.

berquist avatar Jul 04 '20 22:07 berquist

I agree. The only caveat is that we need to somehow ensure all output is the same. A hard-coded set is easier to do that with.

leios avatar Jul 04 '20 23:07 leios

Yes, also my thoughts. Well, we are already going on a system of trust with PR review. One thing that might help is sorting the output. Ideally the output is also not big, which is easily checked.

berquist avatar Jul 05 '20 00:07 berquist

[lang: julia]

ntindle avatar Aug 28 '21 05:08 ntindle