Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HypergraphDistanceMatrix #500

Open
daneelsan opened this issue Oct 30, 2020 · 0 comments
Open

HypergraphDistanceMatrix #500

daneelsan opened this issue Oct 30, 2020 · 0 comments
Labels
feature New functionality, or change in existing functionality

Comments

@daneelsan
Copy link
Collaborator

daneelsan commented Oct 30, 2020

The problem

The function HypergraphDistanceMatrix should compute the distance between any 2 vertices in the hypergraph, similar to GraphDistanceMatrix, where (hypergraph) distance is (roughly) defined as the minimum length of a path that connects both vertices.

Possible solution

One "easy" solution is to use both HypergraphToGraph and GraphDistanceMatrix to compute this:

HypergraphDistanceMatrix[hg_, "Directed"] :=
  GraphDistanceMatrix[HypergraphToGraph[hg, "DirectedDistancePreserving"]]

HypergraphDistanceMatrix[hg_, "Undirected"] :=
  GraphDistanceMatrix[HypergraphToGraph[hg, "UndirectedDistancePreserving"]]
In[]:= vertexList = Sort@*Union@*Catenate;

With[{hg = {{x, x, y, z}, {z, w}, {w, a}}},
 Table[
   {method, TableForm[HypergraphDistanceMatrix[hg, method], TableHeadings -> Table[vertexList@hg, 2]]},
   {method, {"Undirected", "Directed"}}] // Grid[#, Frame -> All, FrameStyle -> LightGray] &
 ]

image

Alternative solutions

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

@daneelsan daneelsan added the feature New functionality, or change in existing functionality label Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality, or change in existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant