Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Jul 29, 2018
1 parent 2ea3ad7 commit b80b9c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions graphi/types/bounded.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@


class Bounded(abc.Graph):
"""
Wrapper to make the values of :py:class:`~.abc.Graph` instances bounded
:param value_bound: bound for all values
The ``value_bound`` must be compatible with all values stored in the graph.
A :py:exc:`TypeError` is raised whenever a value cannot be bounded.
Note that :py:const:`None` is always invalid for ``value_bound``.
.. seealso::
The :py:func:`boundable` decorator for :py:class:`~.abc.Graph` classes.
"""
@property
def undirected(self):
return self._graph.undirected
Expand Down
18 changes: 17 additions & 1 deletion graphi/types/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@


def boundable(graph_class):
"""
Make an implementation of :py:class:`~.abc.Graph` bounded when passing ``value_bound`` to it
.. code:: python
@boundable
class SomeGraph(abc.Graph):
...
unbounded_graph = SomeGraph()
bounded_graph = SomeGraph(value_bound=42)
This provides an implementation agnostic interface to ensure all edge values are bounded.
For any :term:`nodes <node>` ``a`` and ``b``, ``graph[a:b] <= value_bound`` always holds.
Setting an edge value larger than ``value_bound`` removes the edge.
"""
assert issubclass(graph_class, abc.Graph), 'only subclasses of Graph can be bounded'
__new__ = graph_class.__new__

Expand All @@ -26,7 +42,7 @@ def __new_graph__(cls, *args, **kwargs):

def undirectable(graph_class):
"""
Make an implementation of :py:class:`~.abc.Graph` undirectable by passing ``undirected=True`` to it
Make an implementation of :py:class:`~.abc.Graph` undirected when passing ``undirected=True`` to it
.. code:: python
Expand Down

0 comments on commit b80b9c4

Please sign in to comment.