dhgraph

Python Module for Directed Hypergraphs


Keywords
mathematics, hypergraph, directed
License
MIT
Install
pip install dhgraph==1.0.0

Documentation

dhgraph: Python Modlue for Directed Hypergraphs

Introduction

A directed hypergraph is a generalization of digraph. It consists of a set of vertices V and a set of hyperarcs H. A hyperarc is a pair of a nonempty subset of V (called head) and a vertex of V (called tail).

Installation

$ pip install dhgraph

Usage

Let us import dhgraph module, create an empty directed hypergraph object, and add hyperarcs as follows.

As above, add_hyperarc() has a tuple of vertex identifiers, head, as its 1st argument and a vertex identifier, tail, as its 2nd argument, and returns the identifier of a hyperarc having the head and the tail.

The vertices and the hyperarcs added so far can be obtained by get_vertices() and get_hyperarcs(), which respecitvely return a tuple of vertex identifiers and a tuple of hyperarc identifiers, as follows.

Hyperarcs that are incident to a vertex can be obtained by get_hyperarcs_from() and get_hyperarcs_to(), which respectively return a tuple of hyperarcs emanating from a vertex and a tuple of hyperarcs pointing to a vertex, as follows.

Vertices and hyperarcs can be assigned labels, if necessary, when they are added.

If you prefer to use vertex labels, call add_vertex() for all vertices to which labels are to be assigned and then call add_hyperarc(). Otherwise, add_hyperarc() will add vertices appearing in head or tail so that they have vertex identifiers as their labels.

A directed hypergraph can be rendered as follows.

As a result, sample.png will be generated. The arugments of render() are the same as those of render() of Graphviz. See User Guide of Graphviz .

Bugs/Requests/Discussions

Please report bugs and requests from GitHub Issues , and ask questions from GitHub Discussions .

License

Please see LICENSE .