bitwalker / libgraph

A graph data structure library for Elixir projects
MIT License
524 stars 75 forks source link

ArgumentError in Graph.degeneracy/1 for version 0.10.2 #3

Closed yonkeltron closed 7 years ago

yonkeltron commented 7 years ago

Encountered this error (appears to be from ETS) when processing a smallish graph.

** (ArgumentError) argument error
      (stdlib) :ets.update_counter(#Reference<0.2437733789.3691642882.33749>, "heller.name", {2, -1})
    (libgraph) lib/graph.ex:1470: anonymous fn/4 in Graph.decompose_cores/4
      (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    (libgraph) lib/graph.ex:1469: anonymous fn/6 in Graph.decompose_cores/4
      (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    (libgraph) lib/graph.ex:1467: Graph.decompose_cores/4
    (libgraph) lib/graph.ex:1451: Graph.decompose_cores/1
    (libgraph) lib/graph.ex:1395: Graph.degeneracy/1
...snip...

Using Graph.info tells me that it looks like this: %{num_edges: 201, num_vertices: 101, size_in_bytes: 69504, type: :directed} while the printer representation gives me #Graph<type: directed, num_vertices: 101, num_edges: 201>. Neither of these enable me to send you the graph I'm working with. Any tips on how to serialize the graph for transmission to you?

Happy to provide more info since everything's bogus and simulated anyhow!

Thanks, +Jonathan

bitwalker commented 7 years ago

Can you gist up the result of inspect Graph.edges/1? I can reconstruct the graph from that. Looks like my test graphs missed an edge case, sorry about that!

yonkeltron commented 7 years ago

Unfortunately the inspect approach didn't work so well. However, encoding it as JSON worked great!

https://gist.github.com/yonkeltron/e48c10985cfc1933b94e45b7dccfe655

bitwalker commented 7 years ago

Yeah I forgot to mention that you can do inspect graph, structs: false to dump the raw graph (or any struct for that matter!). I'm flying today, but I'll take a look as soon as I can!

bitwalker commented 7 years ago

Found the problem - I forgot to account for self-referential edges. I've pushed the fix to master - looks good on my end though!

yonkeltron commented 7 years ago

Loops, you mean?

On Mon, Jul 24, 2017, 11:18 AM Paul Schoenfelder notifications@github.com wrote:

Found the problem - I forgot to account for self-referential edges. I've pushed the fix to master - looks good on my end though!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitwalker/libgraph/issues/3#issuecomment-317456996, or mute the thread https://github.com/notifications/unsubscribe-auth/AADoO3zE577EnRtFjnNKu0exuzb4wm3Uks5sRLXHgaJpZM4OgkaC .

-- +Jonathan

bitwalker commented 7 years ago

Yeah, specifically loops from a vertex back to itself.

yonkeltron commented 7 years ago

Will this fix go out in a dot release?

bitwalker commented 7 years ago

Yep, I'll get one published today. I wanted to get some improvements into the initial clique detection code to try and optimize it (it's pretty slow on large graphs, which is expected, but I think there may be ways to do better than the current perf profile), but I can release what is there now and do another point release with those improvements.

bitwalker commented 7 years ago

Just pushed 0.11.0 :)