Graphs.jl icon indicating copy to clipboard operation
Graphs.jl copied to clipboard

Hypergraphs feature development advice

Open Philogicatician opened this issue 2 years ago • 7 comments

Hello, I'd like to start developing an implementation of hypergraphs (both directed and undirected) for Graphs.jl and a way to visualize them. I'm aiming for something like the following:

Hypergraphs- Julia example1

This was from me playing around with SimpleHypergraphs.jl which used PyCall.jl to utilize Python's HyperNetX. The issue with the package is that the native Julia implementation doesn't work and it doesn't support directed hypergraphs.

Consequently, I wanted to throw out the idea before I started development to see if the package I make should be following certain implementation or style guidelines (besides the ones listed here). Also, let me know if there's a preferred graph visualization library that is normally used by Graphs.jl so I can make it as compatible as possible. 👍

Philogicatician avatar Mar 19 '22 07:03 Philogicatician

I like that visualization. I think you will have the best luck with Compose.jl. Layout will be the hardest part.

jpfairbanks avatar Mar 19 '22 14:03 jpfairbanks

Please note that SimpleHypergraphs is already totally compatible with Graphs.jl. (more info on the thread cross referenced in the previous post).

julia> h = Hypergraph([1 nothing nothing;
       1 1 nothing;
       nothing nothing 1
       nothing 1 1]
       );

julia> b = BipartiteView(h)
{7, 6} undirected simple Int64 graph

julia> supertype(BipartiteView)
Graphs.SimpleGraphs.AbstractSimpleGraph{Int64}

pszufe avatar Mar 21 '22 12:03 pszufe

Please note that SimpleHypergraphs is already totally compatible with Graphs.jl.

Perfect! In that case, the main issue will be displaying the graph in a way that captures the previous image (but without reaching into Python with PyCall.jl to get HyperNetX) and creating a way to represent directed hypergraphs. I'm thinking something along these lines (but with colors): image

One issue that came to mind for long-term hypergraph functionality is also allowing for oriented hypergraphs (which are a generalization of signed graphs). I'm thinking mainly of the work done by Neff & Rusnak that Rusnak outlines here.

Philogicatician avatar Mar 21 '22 14:03 Philogicatician

There is already a similar visualization in SimpleHypergraphs.jl. It is based on D3, JavaScript and can show hypergraph in a web browser. Have a look at https://pszufe.github.io/SimpleHypergraphs.jl/stable/reference/#SimpleHypergraphs.draw

Try in Jupyter notebook:

draw(h, GraphBased)

pszufe avatar Mar 29 '22 21:03 pszufe

At first I thought that feature was still broken, but it turns out it just took several minutes for it to display the first time. Thanks a lot @pszufe!

Philogicatician avatar Mar 29 '22 23:03 Philogicatician

perhaps it was downloading the JavaScript libs when run for the first time? I see in the other post that you were running it inside VS Code - quite likely it might be quite not suited for VS Code - we have tested it on Firefox and Chrome - I do not know what browser VS Code is using,

pszufe avatar Mar 30 '22 00:03 pszufe

Hi there! Just following up, is your problem solved @Philogicatician ? Can we close the issue?

gdalle avatar May 19 '22 04:05 gdalle