09.02.2015 Views

Sage Reference Manual: Graph Theory - Mirrors

Sage Reference Manual: Graph Theory - Mirrors

Sage Reference Manual: Graph Theory - Mirrors

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Graph</strong> <strong>Theory</strong>, Release 6.1.1<br />

The empty graph is a subgraph of every graph:<br />

sage: g.subgraph_search_count(graphs.Empty<strong>Graph</strong>())<br />

1<br />

TESTS:<br />

Inside of a small graph (trac ticket #13906):<br />

sage: <strong>Graph</strong>(5).subgraph_search_count(<strong>Graph</strong>(1))<br />

5<br />

subgraph_search_iterator(G, induced=False)<br />

Returns an iterator over the labelled copies of G in self.<br />

INPUT:<br />

•G – the graph whose copies we are looking for in self.<br />

•induced – boolean (default: False). Whether or not to iterate over the induced copies of G in<br />

self.<br />

ALGORITHM:<br />

Brute-force search.<br />

OUTPUT:<br />

Iterator over the labelled copies of G in self, as lists. For each value (v 1 , v 2 , ..., v k ) returned,<br />

the first vertex of G is associated with v 1 , the second with v 2 , etc ...<br />

Note: This method also works on digraphs.<br />

See Also:<br />

•subgraph_search() – finds an subgraph isomorphic to H inside of a graph G<br />

•subgraph_search_count() – Counts the number of copies of a graph H inside of a graph G<br />

EXAMPLE:<br />

Iterating through all the labelled P 3 of P 5 :<br />

sage: g = graphs.Path<strong>Graph</strong>(5)<br />

sage: for p in g.subgraph_search_iterator(graphs.Path<strong>Graph</strong>(3)):<br />

... print p<br />

[0, 1, 2]<br />

[1, 2, 3]<br />

[2, 1, 0]<br />

[2, 3, 4]<br />

[3, 2, 1]<br />

[4, 3, 2]<br />

TESTS:<br />

Inside of a small graph (trac ticket #13906):<br />

sage: list(<strong>Graph</strong>(5).subgraph_search_iterator(<strong>Graph</strong>(1)))<br />

[<strong>Graph</strong> on 1 vertex, <strong>Graph</strong> on 1 vertex, <strong>Graph</strong> on 1 vertex, <strong>Graph</strong> on 1 vertex, <strong>Graph</strong> on 1 vert<br />

szeged_index()<br />

Returns the Szeged index of the graph.<br />

152 Chapter 1. <strong>Graph</strong> objects and methods

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!