Examples of graphs#

class sage.categories.examples.graphs.Cycle(n=5)#

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

We conclude by running systematic tests on this graph:

sage: TestSuite(C).run()
class Element#

Bases: ElementWrapper

dimension()#

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
an_element()#

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
edges()#

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)]
vertices()#

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]
sage.categories.examples.graphs.Example#

alias of Cycle