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

Commit

Permalink
use combinatorial polyhedron to obtain the vertex facet graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Feb 14, 2020
1 parent 9a62a52 commit 1e10ebd
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,24 +682,14 @@ def vertex_facet_graph(self, labels=True):
sage: G._immutable
True
"""
# We construct the edges and remove the columns that have all 1s;
# those correspond to faces, that contain all vertices (which happens
# if the polyhedron is not full-dimensional)
G = DiGraph()
if labels:
edges = [[v, f] for f in self.Hrep_generator()
if any(not(f.is_incident(v)) for v in self.Vrep_generator())
for v in self.vertices() if f.is_incident(v)]
else:
# here we obtain this incidence information from the incidence matrix
M = self.incidence_matrix()
edges = [[i, M.ncols()+j] for i, column in enumerate(M.columns())
if any(entry != 1 for entry in column)
for j in range(M.nrows()) if M[j, i] == 1]
G.add_edges(edges)
return G.copy(immutable=True)
Check that :trac:`29188` is fixed::
sage: P = polytopes.cube()
sage: P.vertex_facet_graph().is_isomorphic(P.vertex_facet_graph(False))
True
"""
return self.combinatorial_polyhedron().vertex_facet_graph(names=labels)

def plot(self,
point=None, line=None, polygon=None, # None means unspecified by the user
Expand Down

0 comments on commit 1e10ebd

Please sign in to comment.