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.Cube<strong>Graph</strong>(4)<br />

sage: G.adjacency_matrix()<br />

[0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0]<br />

[1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0]<br />

[1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0]<br />

[0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 0]<br />

[1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0]<br />

[0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0]<br />

[0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0]<br />

[0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1]<br />

[1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0]<br />

[0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 0]<br />

[0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0]<br />

[0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1]<br />

[0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0]<br />

[0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1]<br />

[0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1]<br />

[0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0]<br />

sage: matrix(GF(2),G) # matrix over GF(2)<br />

[0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0]<br />

[1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0]<br />

[1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0]<br />

[0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 0]<br />

[1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0]<br />

[0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0]<br />

[0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0]<br />

[0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1]<br />

[1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0]<br />

[0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 0]<br />

[0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0]<br />

[0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1]<br />

[0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0]<br />

[0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1]<br />

[0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1]<br />

[0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0]<br />

sage: D = Di<strong>Graph</strong>( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } )<br />

sage: D.adjacency_matrix()<br />

[0 1 1 1 0 0]<br />

[1 0 1 0 0 0]<br />

[0 0 0 1 0 0]<br />

[0 0 0 0 1 0]<br />

[1 0 0 0 0 1]<br />

[0 1 0 0 0 0]<br />

TESTS:<br />

sage: graphs.Cube<strong>Graph</strong>(8).adjacency_matrix().parent()<br />

Full MatrixSpace of 256 by 256 dense matrices over Integer Ring<br />

sage: graphs.Cube<strong>Graph</strong>(9).adjacency_matrix().parent()<br />

Full MatrixSpace of 512 by 512 sparse matrices over Integer Ring<br />

all_paths(start, end)<br />

Returns a list of all paths (also lists) between a pair of vertices (start, end) in the (di)graph. If start is the<br />

same vertex as end, then [[start]] is returned – a list containing the 1-vertex, 0-edge path “start”.<br />

EXAMPLES:<br />

1.1. Generic graphs 9

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

Saved successfully!

Ooh no, something went wrong!