Skip to content

Commit

Permalink
Trac #27010: py3: avoid .vertices() in methods _ford_fulkerson, edge_…
Browse files Browse the repository at this point in the history
…cut, bounded_outdegree_orientation and gomory_hu_tree

We fix all doctests errors in py3 of methods
`bounded_outdegree_orientation` and `gomory_hu_tree` of `graph.py` by
avoiding calls to `.vertices()` in these methods and in methods
`edge_cut` and `_ford_fulkerson` of `generic_graph.py`. This also fixes
some doctests in `generic_graph.py`.

URL: https://trac.sagemath.org/27010
Reported by: dcoudert
Ticket author(s): David Coudert
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Jan 23, 2019
2 parents 58d9680 + 0240367 commit 6521233
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6174,7 +6174,7 @@ def edge_cut(self, s, t, value_only=True, use_edge_labels=False, vertices=False,
return_value.append(self.edge_boundary(reachable_from_s))

if vertices:
return_value.append([reachable_from_s, list(set(self.vertices()).difference(reachable_from_s))])
return_value.append([reachable_from_s, list(set(self).difference(reachable_from_s))])

return return_value

Expand Down Expand Up @@ -8741,7 +8741,7 @@ def _ford_fulkerson(self, s, t, use_edge_labels=False, integer=False, value_only
# edge is strictly less than its capacity, or when there exists a back
# arc with non-null flow
residual = DiGraph()
residual.add_vertices(self.vertices())
residual.add_vertices(self)

# Initializing the variables
if directed:
Expand Down
6 changes: 3 additions & 3 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ def bounded_outdegree_orientation(self, bound, solver=None, verbose=False):
if not n:
return DiGraph()

vertices = self.vertices()
vertices = list(self)
vertices_id = {y: x for x,y in enumerate(vertices)}

b = {}
Expand Down Expand Up @@ -7655,9 +7655,9 @@ def gomory_hu_tree(self, algorithm=None):
if not self.is_connected():
g = Graph()
for cc in self.connected_components_subgraphs():
g = g.union(cc._gomory_hu_tree(frozenset(cc.vertices()), algorithm=algorithm))
g = g.union(cc._gomory_hu_tree(frozenset(cc.vertex_iterator()), algorithm=algorithm))
else:
g = self._gomory_hu_tree(frozenset(self.vertices()), algorithm=algorithm)
g = self._gomory_hu_tree(frozenset(self.vertex_iterator()), algorithm=algorithm)

if self.get_pos() is not None:
g.set_pos(dict(self.get_pos()))
Expand Down

0 comments on commit 6521233

Please sign in to comment.