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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

sage: P = Di<strong>Graph</strong>([(0,1)])<br />

sage: B = digraphs.DeBruijn( [’a’,’b’], 2 )<br />

sage: Q = P.cartesian_product(B)<br />

sage: Q.edges(labels=None)<br />

[((0, ’aa’), (0, ’aa’)), ((0, ’aa’), (0, ’ab’)), ((0, ’aa’), (1, ’aa’)), ((0, ’ab’), (0, ’ba<br />

sage: Q.strongly_connected_components_digraph().num_verts()<br />

2<br />

sage: V = Q.strongly_connected_component_containing_vertex( (0, ’aa’) )<br />

sage: B.is_isomorphic( Q.subgraph(V) )<br />

True<br />

categorical_product(other)<br />

Returns the tensor product of self and other.<br />

The tensor product of G and H is the graph L with vertex set V (L) equal to the Cartesian product of the<br />

vertices V (G) and V (H), and ((u, v), (w, x)) is an edge iff - (u, w) is an edge of self, and - (v, x) is an<br />

edge of other.<br />

The tensor product is also known as the categorical product and the kronecker product (refering to the<br />

kronecker matrix product). See Wikipedia article on the Kronecker product.<br />

EXAMPLES:<br />

sage: Z = graphs.Complete<strong>Graph</strong>(2)<br />

sage: C = graphs.Cycle<strong>Graph</strong>(5)<br />

sage: T = C.tensor_product(Z); T<br />

<strong>Graph</strong> on 10 vertices<br />

sage: T.size()<br />

10<br />

sage: T.plot() # long time<br />

sage: D = graphs.Dodecahedral<strong>Graph</strong>()<br />

sage: P = graphs.Petersen<strong>Graph</strong>()<br />

sage: T = D.tensor_product(P); T<br />

<strong>Graph</strong> on 200 vertices<br />

sage: T.size()<br />

900<br />

sage: T.plot() # long time<br />

TESTS:<br />

Tensor product of graphs:<br />

sage: G = <strong>Graph</strong>([(0,1), (1,2)])<br />

sage: H = <strong>Graph</strong>([(’a’,’b’)])<br />

sage: T = G.tensor_product(H)<br />

sage: T.edges(labels=None)<br />

[((0, ’a’), (1, ’b’)), ((0, ’b’), (1, ’a’)), ((1, ’a’), (2, ’b’)), ((1, ’b’), (2, ’a’))]<br />

sage: T.is_isomorphic( H.tensor_product(G) )<br />

True<br />

Tensor product of digraphs:<br />

sage: I = Di<strong>Graph</strong>([(0,1), (1,2)])<br />

sage: J = Di<strong>Graph</strong>([(’a’,’b’)])<br />

sage: T = I.tensor_product(J)<br />

sage: T.edges(labels=None)<br />

[((0, ’a’), (1, ’b’)), ((1, ’a’), (2, ’b’))]<br />

sage: T.is_isomorphic( J.tensor_product(I) )<br />

True<br />

1.1. Generic graphs 23

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

Saved successfully!

Ooh no, something went wrong!