Ask Your Question

# Extraction of a result in an other form

For the following code

pol = Polyhedron(ieqs = [[5, -1/2, -1/4],[-18, 1, 3],[0, 1, 0],  [0, 0, 1]])

vr=pol.Vrepresentation()

vr


the result is

(A vertex at (0, 20), A vertex at (42/5, 16/5), A vertex at (0, 6))


How to have it as

pol= [(0, 20),(42/5, 16/5),(0, 6)] ?

edit retag close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

As you can see, the returned elements are vertices, with their own methods, like the ability to provide its neighbors in the polyhedron.

sage: v = vr[0]
sage: v
A vertex at (0, 20)
sage: type(v)
<class 'sage.geometry.polyhedron.representation.Vertex'>


You can transform a vertex into a tuple as follows:

sage: tuple(v)
(0, 20)


So, to do that for each element of the list, you can just use list comprehension:

sage: [tuple(v) for v in vr]
[(0, 20), (42/5, 16/5), (0, 6)]

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2019-10-02 23:36:04 +0200

Seen: 42 times

Last updated: Oct 02 '19