Skip to content

Conversation

@espottesmith
Copy link
Contributor

This PR implements the quad clustering coefficient for undirected hypergraphs (DOI: 10.1063/5.0188246; see also https://github.com/Gyeong-GyunHa/qch) and defines the diameter of a hypergraph as the maximum distance between any vertices.

initial implementation of BFS distance and the notion of hypergraph
diameter (in terms of both node distances and edge distances)
@pszufe
Copy link
Owner

pszufe commented Oct 9, 2025

Thanks for this implementation!
Here are the comments:

  • It looks that you use Matrix{Bool} as the major type throughout your code. Matrix is non-abstract type and such code seriously limit interoperability - AbstractMatrix should be used instead
  • Matrix{Bool} is a dense matrix while the incidence matrices are sparse. This will be a huge performance bottlenecks for larger hypergraphs.
  • Hypegraphs.jl distinguishes vertex-hyperedge incidence value weight = 0 from a situation when there is no incidence. In the Bool representation you assume that h = Hypergraph(Matrix{Union{Bool,Nothing}}(zeros(Bool, 2,2))) will yield a matrix of ones(Bool, 1, 1) while this might make sense - it should be documented in order to to surprise the user.

In order to provide good performance I could propose (for your consideration):

  • implement SparseHypergraphView{Bool} <: SparseArrays.AbstractSparseMatrixCSC{Bool, Int64}. (it could be perhaps SparseHypergraphView{T} where T <: Real)
  • have your methods accept argument AbstractMatrix{Bool} and iterate the arrays elements differently depending how issparse(arg) resolves.

If we have such implementation this should be both fast with large hypergraphs and flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants