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

sage: C.automorphism_group(orbits=True, return_group=False)<br />

[[’000’, ’001’, ’010’, ’011’, ’100’, ’101’, ’110’, ’111’]]<br />

TESTS:<br />

We get a KeyError when given an invalid partition (trac #6087):<br />

sage: g=graphs.Cube<strong>Graph</strong>(3)<br />

sage: g.relabel()<br />

sage: g.automorphism_group(partition=[[0,1,2],[3,4,5]])<br />

Traceback (most recent call last):<br />

...<br />

KeyError: 6<br />

Labeled automorphism group:<br />

sage: digraphs.DeBruijn(3,2).automorphism_group()<br />

Permutation Group with generators [(’01’,’02’)(’10’,’20’)(’11’,’22’)(’12’,’21’), (’00’,’11’)<br />

sage: d = digraphs.DeBruijn(3,2)<br />

sage: d.allow_multiple_edges(True)<br />

sage: d.add_edge(d.edges()[0])<br />

sage: d.automorphism_group()<br />

Permutation Group with generators [(’01’,’02’)(’10’,’20’)(’11’,’22’)(’12’,’21’)]<br />

The labeling is correct:<br />

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

sage: ag = g.automorphism_group()<br />

sage: for u,v in g.edges(labels = False):<br />

... if len(ag.orbit((u,v),action="OnPairs")) != 30:<br />

... print "ARggggggggggggg !!!"<br />

Empty group, correct domain:<br />

sage: <strong>Graph</strong>({’a’:[’a’], ’b’:[]}).automorphism_group()<br />

Permutation Group with generators [()]<br />

sage: <strong>Graph</strong>({’a’:[’a’], ’b’:[]}).automorphism_group().domain()<br />

{’a’, ’b’}<br />

average_degree()<br />

Returns the average degree of the graph.<br />

The average degree of a graph G = (V, E) is equal to \frac {2|E|}{|V|}.<br />

EXAMPLES:<br />

The average degree of a regular graph is equal to the degree of any vertex:<br />

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

sage: g.average_degree() == 4<br />

True<br />

The average degree of a tree is always strictly less than 2:<br />

sage: g = graphs.RandomGNP(20,.5)<br />

sage: tree = <strong>Graph</strong>()<br />

sage: tree.add_edges(g.min_spanning_tree())<br />

sage: tree.average_degree() < 2<br />

True<br />

For any graph, it is equal to \frac {2|E|}{|V|}:<br />

1.1. Generic graphs 17

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

Saved successfully!

Ooh no, something went wrong!