graphi.types.decorator module

graphi.types.decorator.boundable(graph_class)

Make an implementation of Graph bounded when passing value_bound to it

@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 nodes a and b, graph[a:b] <= value_bound always holds. Setting an edge value larger than value_bound removes the edge.

graphi.types.decorator.undirectable(graph_class)

Make an implementation of Graph undirected when passing undirected=True to it

@undirectable
class SomeGraph(abc.Graph):
    ...

directed_graph = SomeGraph()
undirected_graph = SomeGraph(undirected=True)

This provides an implementation agnostic interface to ensure all edges are undirected. For any nodes a and b, graph[a:b] == graph[b:a] always holds and graph.edges() produces only one of a:b or b:a.