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

allows_multiple_edges()<br />

Returns whether multiple edges are permitted in the (di)graph.<br />

EXAMPLES:<br />

sage: G = <strong>Graph</strong>(multiedges=True,sparse=True); G<br />

Multi-graph on 0 vertices<br />

sage: G.has_multiple_edges()<br />

False<br />

sage: G.allows_multiple_edges()<br />

True<br />

sage: G.add_edges([(0,1)]*3)<br />

sage: G.has_multiple_edges()<br />

True<br />

sage: G.multiple_edges()<br />

[(0, 1, None), (0, 1, None), (0, 1, None)]<br />

sage: G.allow_multiple_edges(False); G<br />

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

sage: G.has_multiple_edges()<br />

False<br />

sage: G.edges()<br />

[(0, 1, None)]<br />

sage: D = Di<strong>Graph</strong>(multiedges=True,sparse=True); D<br />

Multi-digraph on 0 vertices<br />

sage: D.has_multiple_edges()<br />

False<br />

sage: D.allows_multiple_edges()<br />

True<br />

sage: D.add_edges([(0,1)]*3)<br />

sage: D.has_multiple_edges()<br />

True<br />

sage: D.multiple_edges()<br />

[(0, 1, None), (0, 1, None), (0, 1, None)]<br />

sage: D.allow_multiple_edges(False); D<br />

Digraph on 2 vertices<br />

sage: D.has_multiple_edges()<br />

False<br />

sage: D.edges()<br />

[(0, 1, None)]<br />

am(sparse=None, boundary_first=False)<br />

Returns the adjacency matrix of the (di)graph.<br />

Each vertex is represented by its position in the list returned by the vertices() function.<br />

The matrix returned is over the integers. If a different ring is desired, use either the change_ring function<br />

or the matrix function.<br />

INPUT:<br />

•sparse - whether to represent with a sparse matrix<br />

•boundary_first - whether to represent the boundary vertices in the upper left block<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.1. Generic graphs 13

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

Saved successfully!

Ooh no, something went wrong!