Skip to content

Commit

Permalink
Trac #28626: Compute graph of polyhedron with CombinatorialPolyhedron
Browse files Browse the repository at this point in the history
We use `CombinatorialPolyhedron` to compute the graph of
`Polyhedron_base`.

In the case of polyhedra with `lines` aka unpointed polyhedra this
changes the behavior:

- Old behavior: The vertex graph basically ignored the lines, so that
{{{
sage: P = Polyhedron(vertices=my_vertices, rays=my_rays, lines=my_lines)
sage: Q = Polyhedron(vertices=my_vertices, rays=my_rays)
}}}
  have the same graph (assuming the Vrepresentation as `['my_vertices',
'my_rays', 'my_lines']` is minimal).
- New behavior: The vertex graph of a polyhedron with lines contains no
vertices as the polyhedron as no vertices.

We add information about this to the documentation of `vertex_graph`.

We alter a doctest in `combinatorial_automorphism_group` that assumed
the old behavior.

See [https://groups.google.com/d/msg/sage-
devel/lTwb_P0nBEw/_R4vXOxgDAAJ] for the discussion of this change.

URL: https://trac.sagemath.org/28626
Reported by: gh-kliem
Ticket author(s): Jonathan Kliem
Reviewer(s): Dima Pasechnik, Jean-Philippe Labbé
  • Loading branch information
Release Manager committed Apr 25, 2020
2 parents a6b03dd + 01d1907 commit 9355edd
Showing 1 changed file with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6244,6 +6244,14 @@ def vertex_graph(self):
Return a graph in which the vertices correspond to vertices
of the polyhedron, and edges to edges.
..NOTE::
The graph of a polyhedron with lines has no vertices,
as the polyhedron has no vertices (`0`-faces).
The method :meth:`Polyhedron_base:vertices` returns
the defining points in this case.
EXAMPLES::
sage: g3 = polytopes.hypercube(3).vertex_graph(); g3
Expand All @@ -6254,37 +6262,22 @@ def vertex_graph(self):
Graph on 5 vertices
sage: s4.is_eulerian()
True
"""
from itertools import combinations
inequalities = self.inequalities()
vertices = self.vertices()
# Associated to 'v' the inequalities in contact with v
vertex_ineq_incidence = [frozenset([i for i, ineq in enumerate(inequalities) if self._is_zero(ineq.eval(v))])
for i, v in enumerate(vertices)]
The graph of an unbounded polyhedron
is the graph of the bounded complex::
# the dual incidence structure
ineq_vertex_incidence = [set() for _ in range(len(inequalities))]
for v, ineq_list in enumerate(vertex_ineq_incidence):
for ineq in ineq_list:
ineq_vertex_incidence[ineq].add(v)
sage: open_triangle = Polyhedron(vertices=[[1,0], [0,1]],
....: rays =[[1,1]])
sage: open_triangle.vertex_graph()
Graph on 2 vertices
n = len(vertices)
The graph of a polyhedron with lines has no vertices::
pairs = []
for i, j in combinations(range(n), 2):
common_ineq = vertex_ineq_incidence[i] & vertex_ineq_incidence[j]
if not common_ineq: # or len(common_ineq) < d-2:
continue

if len(set.intersection(*[ineq_vertex_incidence[k] for k in common_ineq])) == 2:
pairs.append((i, j))

from sage.graphs.graph import Graph
g = Graph()
g.add_vertices(vertices)
g.add_edges((vertices[i], vertices[j]) for i, j in pairs)
return g
sage: line = Polyhedron(lines=[[0,1]])
sage: line.vertex_graph()
Graph on 0 vertices
"""
return self.combinatorial_polyhedron().vertex_graph()

graph = vertex_graph

Expand Down Expand Up @@ -8288,12 +8281,11 @@ def combinatorial_automorphism_group(self, vertex_graph_only=False):
sage: quadrangle.restricted_automorphism_group()
Permutation Group with generators [()]
Permutations can only exchange vertices with vertices, rays
with rays, and lines with lines::
Permutations of the vertex graph only exchange vertices with vertices::
sage: P = Polyhedron(vertices=[(1,0,0), (1,1,0)], rays=[(1,0,0)], lines=[(0,0,1)])
sage: P = Polyhedron(vertices=[(1,0), (1,1)], rays=[(1,0)])
sage: P.combinatorial_automorphism_group(vertex_graph_only=True)
Permutation Group with generators [(A vertex at (1,0,0),A vertex at (1,1,0))]
Permutation Group with generators [(A vertex at (1,0),A vertex at (1,1))]
This shows an example of two polytopes whose vertex-edge graphs are isomorphic,
but their face_lattices are not isomorphic::
Expand Down

0 comments on commit 9355edd

Please sign in to comment.