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 />

EXAMPLES:<br />

sage: G = graphs.Cycle<strong>Graph</strong>(3)<br />

sage: H = graphs.Cycle<strong>Graph</strong>(4)<br />

sage: J = G.disjoint_union(H); J<br />

Cycle graph disjoint_union Cycle graph: <strong>Graph</strong> on 7 vertices<br />

sage: J.vertices()<br />

[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3)]<br />

sage: J = G.disjoint_union(H, verbose_relabel=False); J<br />

Cycle graph disjoint_union Cycle graph: <strong>Graph</strong> on 7 vertices<br />

sage: J.vertices()<br />

[0, 1, 2, 3, 4, 5, 6]<br />

sage: G=<strong>Graph</strong>({’a’: [’b’]})<br />

sage: G.name("Custom path")<br />

sage: G.name()<br />

’Custom path’<br />

sage: H=graphs.Cycle<strong>Graph</strong>(3)<br />

sage: J=G.disjoint_union(H); J<br />

Custom path disjoint_union Cycle graph: <strong>Graph</strong> on 5 vertices<br />

sage: J.vertices()<br />

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

disjunctive_product(other)<br />

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

The disjunctive product of G and H is the graph L with vertex set V (L) = V (G) × V (H), and<br />

((u, v), (w, x)) is an edge iff either :<br />

•(u, w) is an edge of G, or<br />

•(v, x) is an edge of H.<br />

EXAMPLES:<br />

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

sage: D = Z.disjunctive_product(Z); D<br />

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

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

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

sage: D = C.disjunctive_product(Z); D<br />

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

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

TESTS:<br />

Disjunctive 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.disjunctive_product(H)<br />

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

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

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

True<br />

Disjunctive product of digraphs:<br />

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

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

1.1. Generic graphs 43

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

Saved successfully!

Ooh no, something went wrong!