CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-hypernetx

Python library for the creation and study of hypergraphs with analysis, visualization, and algorithm capabilities

Pending
Overview
Eval results
Files

visualization.mddocs/

Visualization and Drawing

Visualization capabilities for hypergraph display including rubber band layouts, incidence upset plots, and bipartite representations. These functions provide multiple ways to visualize hypergraph structure and relationships.

Capabilities

Primary Drawing Function

Main hypergraph visualization using rubber band layout algorithm that positions nodes and draws hyperedges as enclosing shapes.

def draw(
    H: "Hypergraph",
    **kwargs
) -> Any:
    """
    Draw hypergraph using rubber band layout.
    
    Parameters:
    - H: Input hypergraph
    - **kwargs: Drawing parameters including:
        - pos: Node positions (dict)
        - node_color: Node colors
        - node_size: Node sizes
        - edge_color: Edge colors
        - with_node_labels: Show node labels
        - with_edge_labels: Show edge labels
        - ax: Matplotlib axes object
        - layout: Layout algorithm
        - figsize: Figure size tuple
    
    Returns:
    Matplotlib figure or axes object
    """

Usage example:

import hypernetx as hnx
import matplotlib.pyplot as plt

# Create a simple hypergraph
H = hnx.Hypergraph({'E1': ['A', 'B', 'C'], 'E2': ['B', 'C', 'D']})

# Basic drawing
hnx.draw(H)
plt.show()

# Customized drawing
hnx.draw(H, 
         node_color='lightblue',
         node_size=300,
         edge_color=['red', 'blue'],
         with_node_labels=True,
         with_edge_labels=True,
         figsize=(10, 8))
plt.show()

Incidence Upset Plot

Specialized visualization showing hypergraph structure as an upset plot, which effectively displays set intersections and memberships.

def draw_incidence_upset(
    H: "Hypergraph",
    **kwargs
) -> Any:
    """
    Draw hypergraph as incidence upset plot.
    
    Parameters:
    - H: Input hypergraph
    - **kwargs: Upset plot parameters including:
        - sort_by: Sorting criteria ('cardinality', 'degree')
        - subset_size: Type of subset size display
        - show_counts: Show intersection counts
        - figsize: Figure size tuple
        - min_subset_size: Minimum subset size to display
        - max_subset_size: Maximum subset size to display
    
    Returns:
    Matplotlib figure showing upset plot
    """

Usage example:

import hypernetx as hnx

# Create hypergraph with multiple overlapping edges
H = hnx.Hypergraph({
    'E1': ['A', 'B', 'C'],
    'E2': ['B', 'C', 'D', 'E'], 
    'E3': ['A', 'D'],
    'E4': ['C', 'E', 'F']
})

# Draw upset plot
hnx.draw_incidence_upset(H, 
                        sort_by='cardinality',
                        show_counts=True,
                        figsize=(12, 8))
plt.show()

Bipartite Euler Diagram

Visualization of hypergraph as bipartite graph using Euler diagram representation, showing nodes and edges as separate vertex sets.

def draw_bipartite_using_euler(
    H: "Hypergraph",
    **kwargs
) -> Any:
    """
    Draw hypergraph as bipartite Euler diagram.
    
    Parameters:
    - H: Input hypergraph
    - **kwargs: Bipartite drawing parameters including:
        - node_color: Colors for node vertices
        - edge_color: Colors for edge vertices  
        - node_shape: Shape for node vertices
        - edge_shape: Shape for edge vertices
        - pos: Position layout
        - with_labels: Show vertex labels
        - figsize: Figure size tuple
    
    Returns:
    Matplotlib figure showing bipartite representation
    """

Usage example:

import hypernetx as hnx
import matplotlib.pyplot as plt

# Create hypergraph
H = hnx.Hypergraph({
    'E1': ['A', 'B', 'C'],
    'E2': ['B', 'C', 'D'],
    'E3': ['A', 'D', 'E']
})

# Draw bipartite representation
hnx.draw_bipartite_using_euler(H,
                               node_color='lightblue',
                               edge_color='lightcoral',
                               node_shape='o',
                               edge_shape='s',
                               with_labels=True,
                               figsize=(10, 6))
plt.show()

Install with Tessl CLI

npx tessl i tessl/pypi-hypernetx

docs

algorithms.md

analysis-metrics.md

core-hypergraph.md

index.md

utilities.md

visualization.md

tile.json