pnnl / HyperNetX

Python package for hypergraph analysis and visualization.
https://hypernetx.readthedocs.io
Other
506 stars 86 forks source link

Hyperedges incorrectly being drawn around all nodes #31

Closed epideveloper closed 4 years ago

epideveloper commented 4 years ago

When drawing a hypergraph with 95 nodes and 154 edges, many hyperedges are incorrectly encircling all of the 95 nodes. See the example provided below where no edges contain more than 3 nodes, but most of the 154 hyperedges are being drawn around all nodes.

Output: hypernetx_error

Output (cropped): hypernetx_error_cropped

import matplotlib.pyplot as plt
from hypernetx import *

edges = [
    ["10000546","10040991","10040998"],
    ["10000546","10040991","10043739"],
    ["10001708","10006436","10040991"],
    ["10001708","10021877","10040991"],
    ["10001708","10040991","10040998"],
    ["10001708","10040991","10046304"],
    ["10002086","10040991","10040998"],
    ["10002861","10040991","10040998"],
    ["10003018","10018073","10040991"],
    ["10003018","10040991","10040998"],
    ["10003216","10007963","10040991"],
    ["10003216","10011082","10040991"],
    ["10003216","10040991","10040998"],
    ["10003216","10040991","10057166"],
    ["10003816","10010761","10040991"],
    ["10003816","10012303","10040991"],
    ["10003816","10023213","10040991"],
    ["10003816","10040991","10040998"],
    ["10004994","10040991","10040998"],
    ["10004994","10040991","10041543"],
    ["10005908","10017977","10040991"],
    ["10005908","10018073","10040991"],
    ["10005908","10040991","10040998"],
    ["10005959","10013296","10040991"],
    ["10005959","10040991","10040998"],
    ["10006232","10006291","10040991"],
    ["10006232","10040991","10040998"],
    ["10006291","10040991","10040998"],
    ["10006436","10040991","10040998"],
    ["10007521","10040991","10040998"],
    ["10007963","10040991","10040998"],
    ["10009841","10040991","10040998"],
    ["10010761","10014982","10040991"],
    ["10010761","10040991","10040998"],
    ["10011082","10018073","10040991"],
    ["10011082","10040991","10040998"],
    ["10011082","10040991","10057166"],
    ["10011082","10040991","10079101"],
    ["10011954","10029305","10040991"],
    ["10011954","10040991","10040998"],
    ["10011954","10040991","10082206"],
    ["10012272","10040991","10040998"],
    ["10012272","10040991","10057167"],
    ["10012303","10040991","10040998"],
    ["10012375","10040991","10040998"],
    ["10012653","10034606","10040991"],
    ["10013296","10040991","10040998"],
    ["10013317","10040991","10040998"],
    ["10013317","10040991","10057166"],
    ["10014412","10017977","10040991"],
    ["10014412","10018073","10040991"],
    ["10014412","10038430","10040991"],
    ["10014412","10040991","10040998"],
    ["10014523","10040991","10040998"],
    ["10014982","10027665","10040991"],
    ["10014982","10040991","10040998"],
    ["10015917","10040991","10040998"],
    ["10017528","10017977","10040991"],
    ["10017528","10040991","10040998"],
    ["10017943","10040991","10040998"],
    ["10017969","10027665","10040991"],
    ["10017969","10040991","10040998"],
    ["10017977","10018027","10040991"],
    ["10017977","10018188","10040991"],
    ["10017977","10031013","10040991"],
    ["10017977","10040991","10040998"],
    ["10017977","10040991","10077546"],
    ["10017990","10017991","10040991"],
    ["10017990","10040991","10040998"],
    ["10017991","10040991","10040998"],
    ["10018012","10018073","10040991"],
    ["10018012","10040991","10040998"],
    ["10018027","10040991","10040998"],
    ["10018073","10019280","10040991"],
    ["10018073","10022114","10040991"],
    ["10018073","10040991","10040998"],
    ["10018073","10040991","10047066"],
    ["10018073","10040991","10068775"],
    ["10018073","10040991","10069888"],
    ["10018073","10040991","10074469"],
    ["10018073","10040991","10079101"],
    ["10018188","10021879","10040991"],
    ["10018188","10040991","10040998"],
    ["10018307","10040991","10040998"],
    ["10018424","10040991","10040998"],
    ["10018424","10040991","10057166"],
    ["10019231","10040991","10040998"],
    ["10019231","10040991","10047066"],
    ["10019280","10040991","10040998"],
    ["10019280","10040991","10057166"],
    ["10019654","10040991","10040998"],
    ["10019654","10040991","10047438"],
    ["10021877","10040991","10040998"],
    ["10021877","10040991","10046304"],
    ["10021879","10024970","10040991"],
    ["10021879","10040991","10040998"],
    ["10022114","10029305","10040991"],
    ["10022114","10040991","10040998"],
    ["10022396","10029305","10040991"],
    ["10022958","10040991","10040998"],
    ["10023213","10037546","10040991"],
    ["10023213","10040991","10040998"],
    ["10024324","10040991","10040998"],
    ["10024967","10040991","10040998"],
    ["10024970","10040991","10040998"],
    ["10025320","10040991","10040998"],
    ["10026753","10040991","10040998"],
    ["10027665","10040991","10040998"],
    ["10027946","10040991","10040998"],
    ["10028037","10040991","10040998"],
    ["10028302","10029317","10040991"],
    ["10028302","10040991","10040998"],
    ["10028377","10040991","10040998"],
    ["10028393","10040991","10040998"],
    ["10029107","10038666","10040991"],
    ["10029107","10040991","10040998"],
    ["10029305","10040991","10040998"],
    ["10029317","10040991","10040998"],
    ["10031013","10040991","10040998"],
    ["10033283","10038594","10040991"],
    ["10033283","10040991","10040998"],
    ["10034606","10040991","10040998"],
    ["10035227","10040991","10040998"],
    ["10037454","10038716","10040991"],
    ["10037454","10040991","10040998"],
    ["10037454","10040991","10057166"],
    ["10037546","10040991","10040998"],
    ["10037546","10040991","10057166"],
    ["10038430","10040991","10040998"],
    ["10038594","10040991","10040998"],
    ["10038666","10040991","10040998"],
    ["10038716","10040991","10040998"],
    ["10039628","10040991","10040998"],
    ["10039911","10040991","10040998"],
    ["10040792","10040991","10040998"],
    ["10040792","10040991","10047438"],
    ["10040798","10040991","10040998"],
    ["10040991","10040998"],
    ["10040991","10040998","10041543"],
    ["10040991","10040998","10043739"],
    ["10040991","10040998","10046304"],
    ["10040991","10040998","10046590"],
    ["10040991","10040998","10047066"],
    ["10040991","10040998","10047438"],
    ["10040991","10040998","10047635"],
    ["10040991","10040998","10057166"],
    ["10040991","10040998","10057167"],
    ["10040991","10040998","10068775"],
    ["10040991","10040998","10069888"],
    ["10040991","10040998","10074469"],
    ["10040991","10040998","10077546"],
    ["10040991","10040998","10079101"],
    ["10040991","10040998","10082206"],
    ["10040991","10047066","10074469"]
]

hpgph = Hypergraph(edges)

plt.figure(figsize=(80, 80))
draw(hpgph, ax=plt.subplot(111), with_edge_labels=True)
brendapraggastis commented 4 years ago

There are limits to the number of edges you can draw in limited space. I constructed your hypergraph and found two nodes have disproportionately high degrees and you have multiple singletons, nodes contained in a single edge. I suggest visualizing pieces of your hypergraph by restricting to a subset of nodes. I started by restricting to the 6 nodes with highest degree and collapsed the multi-edges: image

Then I skipped the three nodes with greatest degrees and generated a sequence of plots adding one node at a time to see how the visualization developed. Below is a sequence after adding 36 nodes. I recommend playing with different combinations of nodes based on what relationships you wish to highlight.

image