#13294: Add test for not necessarily induced subgraphs to Graph.is_subgraph()
method
-------------------------------------------+--------------------------------
Reporter: steven | Owner: jason, ncohen, rlm
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-5.3
Component: graph theory | Resolution:
Keywords: graph, induced subgraph | Work issues:
Report Upstream: N/A | Reviewers: David Coudert
Authors: Stefano Leucci | Merged in:
Dependencies: | Stopgaps:
-------------------------------------------+--------------------------------
Changes (by dcoudert):
* status: needs_review => needs_work
* reviewer: => David Coudert
Comment:
Hello,
I agree with Nathann that you have incorrect indentation, but in both if
and else statements. The function should be:
{{{
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
if not isinstance(other,Graph) and not isinstance(other,DiGraph):
raise ValueError('The input parameter must be a Graph or a
DiGraph.')
if induced:
self_verts = self.vertices()
for v in self.vertex_iterator():
if v not in other:
return False
return other.subgraph(self_verts) == self
else:
for v in self.vertex_iterator():
if v not in other:
return False
for e in self.edge_iterator():
if not other.has_edge(e):
return False
return True
}}}
You could also add necessary doc tests.
Another question is the expected behavior of the function when self is a
Graph and other a DiGraph. If the answer is always False, then you could
add a test before the {{{if induced:}}} statement. However, what if other
has vertices but no edges?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13294#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.