Opened 10 years ago
Closed 9 years ago
#10139 closed defect (duplicate)
Problem found in graphs.is_planar() when the graph has no edges.
Reported by: | edward.scheinerman | Owned by: | jason, ncohen, rlm |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | graph theory | Keywords: | |
Cc: | brunellus | Merged in: | |
Authors: | Reviewers: | Nathann Cohen | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The is_planar method for graphs includes a set_embedding argument that saves the combinatorial embedding of the graph (if it's planar). In this example, it works properly:
sage: g = graphs.WheelGraph?(6) sage: g.is_planar(set_embedding=True) True sage: g.get_embedding() {0: [1, 5, 4, 3, 2], 1: [2, 5, 0], 2: [0, 3, 1], 3: [0, 4, 2], 4: [0, 5, 3], 5: [0, 1, 4]}
However, is we apply this method to a graph with no edges, a problem arises:
sage: g = graphs.EmptyGraph?() sage: g.add_vertices(range(6)) sage: g.is_planar(set_embedding=True)
AttributeError? Traceback (most recent call last)
/home/ers/<ipython console> in <module>()
/usr/public/share/sage/local/lib/python2.6/site-packages/sage/graphs/generic_graph.pyc in is_planar(self, on_embedding, kuratowski, set_embedding, set_pos)
2438 self._pos = G._pos 2439 if set_embedding:
-> 2440 self._embedding = G._embedding
2441 return planar 2442
AttributeError?: 'Graph' object has no attribute '_embedding'
Once we add an edge to this graph, all is well:
sage: g.add_edge(0,1) sage: sage: g.is_planar(set_embedding=True) True sage: g.get_embedding() {0: [1], 1: [0], 2: [], 3: [], 4: [], 5: []}
Change History (5)
comment:1 Changed 10 years ago by
- Component changed from PLEASE CHANGE to graph theory
- Owner changed from tbd to jason, ncohen, rlm
comment:2 Changed 9 years ago by
- Cc brunellus added
comment:3 Changed 9 years ago by
- Status changed from new to needs_review
comment:4 Changed 9 years ago by
- Milestone set to sage-duplicate/invalid/wontfix
- Status changed from needs_review to positive_review
comment:5 Changed 9 years ago by
- Resolution set to duplicate
- Reviewers set to Nathann Cohen
- Status changed from positive_review to closed
The patch from #12134 should solve this problem.