Examples of graphs#
- class sage.categories.examples.graphs.Cycle(n=5)[source]#
Bases:
UniqueRepresentation
,Parent
An example of a graph: the cycle of length \(n\).
This class illustrates a minimal implementation of a graph.
EXAMPLES:
sage: from sage.categories.graphs import Graphs sage: C = Graphs().example(); C An example of a graph: the 5-cycle sage: C.category() Category of graphs
>>> from sage.all import * >>> from sage.categories.graphs import Graphs >>> C = Graphs().example(); C An example of a graph: the 5-cycle >>> C.category() Category of graphs
We conclude by running systematic tests on this graph:
sage: TestSuite(C).run()
>>> from sage.all import * >>> TestSuite(C).run()
- class Element[source]#
Bases:
ElementWrapper
- dimension()[source]#
Return the dimension of
self
.EXAMPLES:
sage: from sage.categories.graphs import Graphs sage: C = Graphs().example() sage: e = C.edges()[0] sage: e.dimension() 2 sage: v = C.vertices()[0] sage: v.dimension() 1
>>> from sage.all import * >>> from sage.categories.graphs import Graphs >>> C = Graphs().example() >>> e = C.edges()[Integer(0)] >>> e.dimension() 2 >>> v = C.vertices()[Integer(0)] >>> v.dimension() 1
- an_element()[source]#
Return an element of the graph, as per
Sets.ParentMethods.an_element()
.EXAMPLES:
sage: from sage.categories.graphs import Graphs sage: C = Graphs().example() sage: C.an_element() 0
>>> from sage.all import * >>> from sage.categories.graphs import Graphs >>> C = Graphs().example() >>> C.an_element() 0
- edges()[source]#
Return the edges of
self
.EXAMPLES:
sage: from sage.categories.graphs import Graphs sage: C = Graphs().example() sage: C.edges() [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)]
>>> from sage.all import * >>> from sage.categories.graphs import Graphs >>> C = Graphs().example() >>> C.edges() [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)]
- vertices()[source]#
Return the vertices of
self
.EXAMPLES:
sage: from sage.categories.graphs import Graphs sage: C = Graphs().example() sage: C.vertices() [0, 1, 2, 3, 4]
>>> from sage.all import * >>> from sage.categories.graphs import Graphs >>> C = Graphs().example() >>> C.vertices() [0, 1, 2, 3, 4]