Skip to content

Commit

Permalink
Bounded and Undirected give access to attributes of underlying graph
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Jul 31, 2018
1 parent b80b9c4 commit cb39fdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions graphi/types/bounded.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def _ensure_bounds(self):
for tail, head in blacklist:
del self._graph[tail:head]

def __getattr__(self, item):
return getattr(self._graph, item)

def __setattr__(self, key, value):
if key not in ('_graph', 'value_bound'):
setattr(self._graph, key, value)
object.__setattr__(self, key, value)

def __getitem__(self, item):
return self._graph[item]

Expand Down
8 changes: 8 additions & 0 deletions graphi/types/undirected.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def _ensure_symmetry(self):
if graph_diff:
graph.update(graph_diff)

def __getattr__(self, item):
return getattr(self._graph, item)

def __setattr__(self, key, value):
if key != '_graph':
setattr(self._graph, key, value)
object.__setattr__(self, key, value)

def __getitem__(self, item):
return self._graph[item]

Expand Down

0 comments on commit cb39fdd

Please sign in to comment.