Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'public/28603' of git://trac.sagemath.org/sage into publ…
Browse files Browse the repository at this point in the history
…ic/28626
  • Loading branch information
Jonathan Kliem committed Oct 18, 2019
2 parents b89610e + ecb7986 commit 767eb74
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Obtaining edges and ridges::
sage: C.ridges(names=False)[:2]
((6, 7), (5, 7))
Edge-graph and ridge-graph::
Vertex-graph and ridge-graph::
sage: C.edge_graph()
sage: C.vertex_graph()
Graph on 16 vertices
sage: C.ridge_graph()
Graph on 8 vertices
Expand Down Expand Up @@ -929,6 +929,39 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef size_t j
return tuple((vertex_one(j), vertex_two(j)) for j in range(self._n_edges))

def vertex_graph(self, names=True):
r"""
Return a graph in which the vertices correspond to vertices
of the polyhedron, and edges to bounded rank 1 faces.
If ``names`` is set to ``False``, the Vrepresentatives will
carry names according to the indexing of the Vrepresentation.
EXAMPLES::
sage: P = polytopes.cyclic_polytope(3,5)
sage: C = CombinatorialPolyhedron(P)
sage: C.vertex_graph()
Graph on 5 vertices
sage: G = C.vertex_graph()
sage: sorted(G.degree())
[3, 3, 4, 4, 4]
sage: P = Polyhedron(rays=[[1]])
sage: C = CombinatorialPolyhedron(P)
sage: C.graph()
Graph on 1 vertex
"""
vertices = self.vertices(names=names)

# Getting the bounded edges.
edges = tuple(edge for edge in self.edges(names=names)
if edge[0] in vertices and edge[1] in vertices)

return Graph([vertices, edges], format="vertices_and_edges")

graph = vertex_graph

def edge_graph(self, names=True):
r"""
Return the edge graph.
Expand All @@ -941,11 +974,15 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: P = polytopes.cyclic_polytope(3,5)
sage: C = CombinatorialPolyhedron(P)
sage: C.edge_graph()
doctest:...: DeprecationWarning: the method edge_graph of CombinatorialPolyhedron is deprecated; use vertex_graph
See https://trac.sagemath.org/28603 for details.
Graph on 5 vertices
sage: G = C.edge_graph()
sage: sorted(G.degree())
[3, 3, 4, 4, 4]
"""
from sage.misc.superseded import deprecation
deprecation(28603, "the method edge_graph of CombinatorialPolyhedron is deprecated; use vertex_graph", 3)
return Graph(self.edges(names=names), format="list_of_edges")

def ridges(self, add_equalities=False, names=True):
Expand Down

0 comments on commit 767eb74

Please sign in to comment.