From 3f0f5954295fd3abf5a496d9870e88d8ea806fb7 Mon Sep 17 00:00:00 2001 From: Mark Bonicillo Date: Thu, 4 May 2023 01:15:06 -0700 Subject: [PATCH 1/2] Update LICENSE.rst, change versioning tool --- .cz.toml | 21 +++++++++++ LICENSE.rst | 2 +- docs/source/_static/copybutton.js | 62 ------------------------------- docs/source/conf.py | 6 +-- setup.cfg | 12 ------ 5 files changed, 25 insertions(+), 78 deletions(-) create mode 100644 .cz.toml delete mode 100644 docs/source/_static/copybutton.js diff --git a/.cz.toml b/.cz.toml new file mode 100644 index 00000000..048be1a0 --- /dev/null +++ b/.cz.toml @@ -0,0 +1,21 @@ +[tool.commitizen] +name = "cz_conventional_commits" +version = "2.0" +version_files = [ + "setup.py", + "docs/source/conf.py", + "hypernetx/__init__.py" +] +update_changelog_on_bump = false +style = [ + ["qmark", "fg:#ff9d00 bold"], + ["question", "bold"], + ["answer", "fg:#ff9d00 bold"], + ["pointer", "fg:#ff9d00 bold"], + ["highlighted", "fg:#ff9d00 bold"], + ["selected", "fg:#cc5454"], + ["separator", "fg:#cc5454"], + ["instruction", ""], + ["text", ""], + ["disabled", "fg:#858585 italic"] +] diff --git a/LICENSE.rst b/LICENSE.rst index 27a3f68e..6401b05d 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -5,7 +5,7 @@ License HyperNetX -Copyright © 2018, Battelle Memorial Institute +Copyright © 2023, Battelle Memorial Institute Battelle Memorial Institute (hereinafter Battelle) hereby grants permission to any person or entity lawfully obtaining a copy of this software and associated diff --git a/docs/source/_static/copybutton.js b/docs/source/_static/copybutton.js deleted file mode 100644 index d0580c42..00000000 --- a/docs/source/_static/copybutton.js +++ /dev/null @@ -1,62 +0,0 @@ -/* This script from Doc/tools/static/copybutton.js in CPython distribution */ -$(document).ready(function() { - /* Add a [>>>] button on the top-right corner of code samples to hide - * the >>> and ... prompts and the output and thus make the code - * copyable. */ - var div = $('.highlight-python .highlight,' + - '.highlight-default .highlight') - var pre = div.find('pre'); - - // get the styles from the current theme - pre.parent().parent().css('position', 'relative'); - var hide_text = 'Hide the prompts and output'; - var show_text = 'Show the prompts and output'; - var border_width = pre.css('border-top-width'); - var border_style = pre.css('border-top-style'); - var border_color = pre.css('border-top-color'); - var button_styles = { - 'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0', - 'border-color': border_color, 'border-style': border_style, - 'border-width': border_width, 'color': border_color, 'text-size': '75%', - 'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em', - 'border-radius': '0 3px 0 0' - } - - // create and add the button to all the code blocks that contain >>> - div.each(function(index) { - var jthis = $(this); - if (jthis.find('.gp').length > 0) { - var button = $('>>>'); - button.css(button_styles) - button.attr('title', hide_text); - button.data('hidden', 'false'); - jthis.prepend(button); - } - // tracebacks (.gt) contain bare text elements that need to be - // wrapped in a span to work with .nextUntil() (see later) - jthis.find('pre:has(.gt)').contents().filter(function() { - return ((this.nodeType == 3) && (this.data.trim().length > 0)); - }).wrap(''); - }); - - // define the behavior of the button when it's clicked - $('.copybutton').click(function(e){ - e.preventDefault(); - var button = $(this); - if (button.data('hidden') === 'false') { - // hide the code output - button.parent().find('.go, .gp, .gt').hide(); - button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); - button.css('text-decoration', 'line-through'); - button.attr('title', show_text); - button.data('hidden', 'true'); - } else { - // show the code output - button.parent().find('.go, .gp, .gt').show(); - button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); - button.css('text-decoration', 'none'); - button.attr('title', hide_text); - button.data('hidden', 'false'); - } - }); -}); diff --git a/docs/source/conf.py b/docs/source/conf.py index 516fd26f..ac957b08 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -377,6 +377,6 @@ # If false, no index is generated. # epub_use_index = True - -def setup(app): - app.add_js_file("copybutton.js") +# Remove the command prompts such as >>> when copying code snippets from copybutton +# see https://sphinx-copybutton.readthedocs.io/en/latest/use.html +copybutton_exclude = '.linenos, .gp' diff --git a/setup.cfg b/setup.cfg index 5dbdc133..fdef6e24 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,3 @@ -[bumpversion] -current_version = 2.0 -commit = True -tag = True -allow_dirty = True - -[bumpversion:file:docs/source/conf.py] - -[bumpversion:file:hypernetx/__init__.py] - -[bumpversion:file:setup.py] - [mypy-setup.py] ignore_errors = True From 71a77b60c476e00fa7aeea9fc3b7e161402296f0 Mon Sep 17 00:00:00 2001 From: Mark Bonicillo Date: Thu, 4 May 2023 03:23:46 -0700 Subject: [PATCH 2/2] Add figures and captioning --- docs/source/conf.py | 4 + docs/source/hypergraph101.rst | 250 ++++++++++++++++++++++------------ 2 files changed, 164 insertions(+), 90 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ac957b08..4fcfe39a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -380,3 +380,7 @@ # Remove the command prompts such as >>> when copying code snippets from copybutton # see https://sphinx-copybutton.readthedocs.io/en/latest/use.html copybutton_exclude = '.linenos, .gp' + +# tables and code-blocks are automatically numbered if they have a caption. +# See https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-numfig +numfig = True diff --git a/docs/source/hypergraph101.rst b/docs/source/hypergraph101.rst index 73f20e56..a393545a 100644 --- a/docs/source/hypergraph101.rst +++ b/docs/source/hypergraph101.rst @@ -38,58 +38,127 @@ matrix** :math:`A_{n \times n}` where :math:`n=|V|`, where an now also :math:`m=|E|`, and an :math:`i,j` entry in :math:`I` is now 1 if the vertex :math:`v_i` is in edge :math:`e_j`. -.. container:: float - :name: exgraph +.. _f1: +.. figure:: images/exgraph.png + :class: with-border + :width: 300 + :align: center + + Caption + +.. _t1: +.. list-table:: Adjacency matrix :math:`A` of a graph. + :header-rows: 1 + :align: center + + * - + - Andrews + - Bailey + - Carter + - Davis + * - Andrews + - 0 + - 1 + - 1 + - 1 + * - Bailey + - 1 + - 0 + - 1 + - 0 + * - Carter + - 1 + - 1 + - 0 + - 1 + * - Davis + - 1 + - 0 + - 1 + - 1 + +.. _t2: +.. list-table:: Incidence matrix :math:`I` of a graph. + :header-rows: 1 + :align: center + + * - + - 1 + - 2 + - 3 + - 4 + - 5 + * - Andrews + - 1 + - 1 + - 0 + - 1 + - 0 + * - Bailey + - 0 + - 0 + - 0 + - 1 + - 1 + * - Carter + - 0 + - 1 + - 1 + - 0 + - 1 + * - Davis + - 1 + - 0 + - 1 + - 0 + - 0 + + +.. _label3: +.. figure:: images/biblio_hg.png + :class: with-border + :width: 400 + :align: center + + Caption + +.. _t3: +.. list-table:: Incidence matrix I of a hypergraph. + :header-rows: 1 + :align: center + + * - + - 1 + - 2 + - 3 + - 4 + - 5 + * - Andrews + - 1 + - 1 + - 0 + - 1 + - 0 + * - Bailey + - 0 + - 0 + - 0 + - 1 + - 1 + * - Carter + - 0 + - 1 + - 0 + - 0 + - 1 + * - Davis + - 1 + - 1 + - 1 + - 0 + - 0 - .. container:: center - |image1| - -.. container:: center - - .. table:: Adjacency matrix :math:`A` of a graph. - - ======= ======= ====== ====== ===== - \ Andrews Bailey Carter Davis - ======= ======= ====== ====== ===== - Andrews 0 1 1 1 - Bailey 1 0 1 0 - Carter 1 1 0 1 - Davis 1 0 1 0 - ======= ======= ====== ====== ===== - -.. container:: center - - .. table:: Incidence matrix :math:`I` of a graph. - - ======= = = = = = - \ 1 2 3 4 5 - ======= = = = = = - Andrews 1 1 0 1 0 - Bailey 0 0 0 1 1 - Carter 0 1 1 0 1 - Davis 1 0 1 0 0 - ======= = = = = = - -.. container:: float - :name: biblio_hg - - .. container:: center - - |image2| - -.. container:: center - - .. table:: Incidence matrix :math:`I` of a hypergraph. - - ======= = = = = = - \ 1 2 3 4 5 - ======= = = = = = - Andrews 1 1 0 1 0 - Bailey 0 0 0 1 1 - Carter 0 1 0 0 1 - Davis 1 1 1 0 0 - ======= = = = = = Notice that in the incidence matrix :math:`I` of a gentle graph :math:`G`, it is necessarily the case that every column must have @@ -142,12 +211,15 @@ are swapped: we now have :math:`H^* = \langle E, V \rangle` where it’s :math:`E` that is a set of vertices, and the now edges :math:`v \in V, v \subseteq E` are subsets of those vertices. -.. container:: float - :name: dual - .. container:: center +.. _f3: +.. figure:: images/dual.png + :class: with-border + :width: 400 + :align: center + + Caption - |image3| Just like the “primal” hypergraph :math:`H` has a 2-section, so does the dual. This is called the **line graph**, and it is an important @@ -163,12 +235,16 @@ union of cycles would that be true. Also note that in order to calculate the line graph of a graph :math:`G`, one needs to work through its dual hypergraph :math:`G^*`. -.. container:: float - :name: dual2 - .. container:: center +.. _f4: +.. figure:: images/dual2.png + :class: with-border + :width: 400 + :align: center + + Caption + - |image4| Edge Intersections Have Size ---------------------------- @@ -225,12 +301,15 @@ walks in a hypergraph. While both have length 2 (counting edgewise, and recalling origin zero), the one on the left has width 1, and that on the right width 3. -.. container:: float - :name: swalks - .. container:: center +.. _f5: +.. figure:: images/swalks.png + :class: with-border + :width: 600 + :align: center + + Caption - |image5| Towards Less Gentle Things ========================== @@ -268,12 +347,14 @@ hypergraph :math:`H` for every bipartite graph :math:`G` is evident, but not all operations carry over unambiguously between hypergraphs and their bipartite versions. -.. container:: float - :name: bicolored1 +.. _f6: +.. figure:: images/bicolored1.png + :class: with-border + :width: 200 + :align: center - .. container:: center + Caption - |image6| Even more generally, the Boolean incidence matrix :math:`I` of a hypergraph :math:`H` can be taken as the characteristic matrix of a @@ -291,12 +372,14 @@ how groups of vertices are included in groups of edges, and vice versa. Fig. refex shows the **concept lattice** [3], perhaps the most important of these structures, determined by our example. -.. container:: float - :name: ex +.. _f7: +.. figure:: images/ex.png + :class: with-border + :width: 450 + :align: center - .. container:: center + Caption - |image7| Finally, the strength of hypergraphs is their ability to model multi-way interactions. Similarly, mathematical topology is concerned with how @@ -315,12 +398,14 @@ topological methods such as persistent homology. In this way hypergraphs form a perfect bridge from network science to computational topology in general. -.. container:: float - :name: simplicial +.. _f8: +.. figure:: images/simplicial.png + :class: with-border + :width: 400 + :align: center - .. container:: center + Caption - |image8| Non-Gentle Graphs and Hypergraphs --------------------------------- @@ -377,19 +462,4 @@ Hypergraph Walks”, *EPJ Data Science*, v. **9**:16, [3] Ganter, Bernhard and Wille, Rudolf: (1999) *Formal Concept Analysis*, Springer-Verlag -.. |image1| image:: images/exgraph.png - :width: 300 -.. |image2| image:: images/biblio_hg.png - :width: 400 -.. |image3| image:: images/dual.png - :width: 400 -.. |image4| image:: images/dual2.png - :width: 400 -.. |image5| image:: images/swalks.png - :width: 600 -.. |image6| image:: images/bicolored1.png - :width: 200 -.. |image7| image:: images/ex.png - :width: 450 -.. |image8| image:: images/simplicial.png - :width: 400 +