Ticket #2473 (closed defect: fixed)
[with patch, positive review] BipartiteGraph.__init__ does not properly initialize for some inputs
| Reported by: | rhinton | Owned by: | rlm |
|---|---|---|---|
| Priority: | major | Milestone: | sage-2.10.4 |
| Component: | graph theory | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
BipartiteGraph.init does not call the base class init for some inputs, leaving the object unusable. For example,
sage: B = BipartiteGraph(None) sage: B
will throw an exception because the base class attributes have not been initialized. The attached patch ensures the base class init is called.
Attachments
Change History
comment:1 Changed 5 years ago by rlm
- Summary changed from [with patch, needs review] BipartiteGraph.__init__ does not properly initialize for some inputs to [with patch, negative review] BipartiteGraph.__init__ does not properly initialize for some inputs
comment:2 Changed 5 years ago by rhinton
- Summary changed from [with patch, negative review] BipartiteGraph.__init__ does not properly initialize for some inputs to [with patch, needs review] BipartiteGraph.__init__ does not properly initialize for some inputs
The updated patch, I believe, addresses your concerns. It also fixes several more bugs.
comment:4 Changed 5 years ago by rlm
Some notes:
- "TESTS" should actually be labeled "EXAMPLE" or "EXAMPLES". This is just the convention.
- Comments in the examples don't need "#"; see many other doctests for examples of the formatting.
- I've moved the networkx import further down so it only happens if it needs to. This import, if it hasn't been done before, takes several seconds... (I know this doesn't seem to make much sense now, but soon we won't be importing networkx by default whenever we have a graph, so it will make sense eventually.)
Changed 5 years ago by rlm
-
attachment
2473-ref.patch
added
Apply bipartite_graph_input.2.patch, then this.
comment:5 Changed 5 years ago by rlm
- Summary changed from [with patch, needs review] BipartiteGraph.__init__ does not properly initialize for some inputs to [with patch, positive review] BipartiteGraph.__init__ does not properly initialize for some inputs
- Milestone changed from sage-2.11 to sage-2.10.4
Note: See
TracTickets for help on using
tickets.

The problem with this approach is it allows one to construct graphs which are not bipartite, but they will be instances of BipartiteGraph?. What should be done instead is to raise a NotImplementedError?, so that the user knows that the initialization failed. This problem is a small part of the much bigger task in ticket #1941, which is one of the next things I'll be doing. Watch for a patch in the next few days, perhaps...