bug in Graph is_subgraph method

36 views
Skip to first unread message

Craig E Larson

unread,
May 2, 2015, 3:13:23 AM5/2/15
to sage-s...@googlegroups.com
Graph("E`oo") is the disjoint union of 2 triangles. Graph("ExSW") is two triangles with 2 more edges connecting them. So the first graph is a subgraph (a non-induced subgraph) of the second graph. But Sage reports that it is not. Both graphs have order 6.

sage: h=Graph("E`oo")
sage: g=Graph("ExSW")
sage: h.is_subgraph(g,induced=False)
False

This behavior is in "Sage Version 6.5, Release Date: 2015-02-17".



Vincent Delecroix

unread,
May 2, 2015, 3:50:38 AM5/2/15
to sage-s...@googlegroups.com
If you consider the documentation of the function you will see

def is_subgraph(self, other, induced=True):
"""
Tests whether ``self`` is a subgraph of ``other``.

.. WARNING::

Please note that this method does not check whether ``self``
contains a subgraph *isomorphic* to ``other``, but only if it
directly contains it as a subgraph !

Now your two triangles have labels 0,1,4 and 2,3,5. Which are different
from the one in "ExSW". So this method returns False as expected.

You can access the documentation of any function in Sage with the
question mark (and with two you access the source code).

sage: h.is_subgraph?

Vincent
Reply all
Reply to author
Forward
0 new messages