Ask Your Question

stefanutti's profile - activity

2018-08-27 23:05:21 -0600 received badge  Famous Question (source)
2018-08-27 23:05:21 -0600 received badge  Notable Question (source)
2018-04-14 07:06:02 -0600 received badge  Notable Question (source)
2017-04-30 09:53:33 -0600 received badge  Popular Question (source)
2016-06-23 06:58:27 -0600 received badge  Enthusiast
2016-06-21 04:45:42 -0600 answered a question Logging failing after a while

I solved using this: sage_server.MAX_OUTPUT_MESSAGES = 10000000 Also a restart between runs solves the issue.

2016-06-10 14:01:48 -0600 commented answer How to create random cubic planar graphs?

Thanks :-) Is everything so easy in sage and python?

2016-06-10 12:53:52 -0600 received badge  Popular Question (source)
2016-06-10 12:00:32 -0600 received badge  Commentator
2016-06-10 12:00:32 -0600 commented answer How to create random cubic planar graphs?

I mean:

The first is: [ ( (),(), None), (),(), None), ...) ] The second is: [ (), (), ... ]

2016-06-10 11:57:42 -0600 commented answer How to create random cubic planar graphs?

G = simplicial_complexes.RandomTwoSphere(5).flip_graph() Using G.edges() it returns this: [((0, 1, 2), (0, 1, 'b'), None), ((0, 1, 2), (0, 2, 'a'), None), ((0, 1, 2), (1, 2, 'a'), None), ((0, 1, 'b'), (0, 'a', 'b'), None), ((0, 1, 'b'), (1, 'a', 'b'), None), ((0, 2, 'a'), (0, 'a', 'b'), None), ((0, 2, 'a'), (1, 2, 'a'), None), ((0, 'a', 'b'), (1, 'a', 'b'), None), ((1, 2, 'a'), (1, 'a', 'b'), None)]) But normally if I create the Graph manually (another Graph) it returns this: [(1, 2, '1-2'), (1, 5, '5-1'), (1, 6, '1-6'), (2, 3, '2-3'), (2, 10, '2-10'), (3, 4, '3-4'), (3, 12, '3-12'), (4, 5, '4-5'), (4, 11, '4-11'), (5, 7, '5-7'), (6, 7, '6-7'), (6, 8, '6-8'), (7, 9, '7-9'), (8, 9, '8-9'), (8, 10, '8-10'), (9, 11, '9-11'), (10, 12, '10-12'), (11, 12, '12-11')])

Do you know why it is diff?
2016-06-10 06:30:19 -0600 commented question Logging failing after a while

I solved using this:

sage_server.MAX_OUTPUT_MESSAGES = 10000000

Also a restart between runs solves the issue.

2016-06-10 03:52:16 -0600 commented question Logging failing after a while

I'm running inside the free cloud sage machines. The link to reproduce the problem is here.

I'can execute it 2 times and at the third it breaks!

https://cloud.sagemath.com/projects/c...

2016-06-09 09:09:02 -0600 asked a question Logging failing after a while

Hi,

I have a program that if I run multiple times inside the cloud sage worksheet, after a while (3-4 runs) gets a strange KeyboardInterrupt error.

Do you know what it is

Here is the code to reproduce the problem:

import logging
import logging.config
import logging.handlers

import sys

# Set logging facilities
#
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
loggingStreamHandler = logging.StreamHandler(sys.stdout)
loggingStreamHandler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s --- %(message)s'))
logger.addHandler(loggingStreamHandler)

for i in range(100):
    logger.info ("Ciaooooooo: %s", 1000)

logger.info ("End: %s", 1000)

2016-06-09 14:06:18,765 - INFO --- Ciaooooooo: 1000
2016-06-09 14:06:18,766 - INFO --- Ciaooooooo: 1000
2016-06-09 14:06:18,767 - INFO --- Ciaooooooo: 1000
2016-06-09 14:06:18,767 - INFO --- Ciaooooooo: 1000
2016-06-09 14:06:18,768 - INFO --- Ciaooooooo: 1000
Error in lines 12-13
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 2, in <module>
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 1165, in info
    self._log(INFO, msg, args, **kwargs)
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 1284, in _log
    self.handle(record)
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 1294, in handle
    self.callHandlers(record)
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 1334, in callHandlers
    hdlr.handle(record)
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 757, in handle
    self.emit(record)
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 883, in emit
    self.flush()
  File "/projects/sage/sage-6.10/local/lib/python/logging/__init__.py", line 843, in flush
    self.stream.flush()
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 369, in flush
    self._f(self._buf, done=done)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1016, in stdout
    self._send_output(stdout=stdout, done=done, id=self._id, once=once)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 529, in _send_output
    raise KeyboardInterrupt
KeyboardInterrupt
    ​
2016-05-31 17:19:19 -0600 commented answer show() does not show in the right place

It did work! Thanks you

2016-05-31 17:14:45 -0600 commented question How do I get the external face of a planar embedded graph?

Yes, I needed to get the external face respect to the particular planar embedding computed by the G.layout(layout = "planar", save_pos = True)

After the "planar embedding", the position of the vertices should be set (wikipedia: in which points of Σ are associated to vertices) and the external face shoud be also set.

In other words, as far as I know, yes you can embed the graph in many ways depending which face of the graph you want it to be the external face, but for a particular planar embedding the external face is set.

Anyway, at the end I decided to remove edges even if they were on the externall face.

2016-05-31 11:29:53 -0600 commented question show() does not show in the right place

I'm using the cloud sagemath worksheet. sagews

2016-05-31 10:49:25 -0600 received badge  Editor (source)
2016-05-31 04:27:19 -0600 commented question show() does not show in the right place

It should show between the BEFORE and AFTER prints, but actually if you run the code, it will appear right before the first print: print ("BEFORE SHOW ", i)

2016-05-31 03:36:00 -0600 asked a question show() does not show in the right place

Why the show() funtion does not show in the right position?

It should show between the BEFORE and AFTER prints, but actually if you run the code, it will appear right before the first print (see the code): print ("BEFORE SHOW ", i)

print ("Create a graph")
G = Graph(sparse=True)
G.allow_multiple_edges(True)
G.add_edge(1,2,"blue")
G.add_edge(2,3,"green")
G.add_edge(3,1,"red")
G.add_edge(1,4,"green")
G.add_edge(2,4,"red")
G.add_edge(3,4,"blue")

for i in range(5):
    print ("BEFORE SHOW ", i)
    show(G)
    print ("AFTER SHOW ", i)

    print ("BEFORE PLOT ", i)
    G.plot()
    print ("AFTER PLOT ", i)
2016-05-23 16:34:42 -0600 received badge  Supporter (source)
2016-05-22 21:05:35 -0600 received badge  Student (source)
2016-05-19 03:56:46 -0600 commented question VirtualBox Error During Sage Installation

I have the same problem with Sage 7.2. Did someone find a solution?

2016-05-15 07:49:16 -0600 received badge  Scholar (source)
2016-05-15 05:19:06 -0600 commented answer How to create random cubic planar graphs?

I haven't found the RandomTwoSphere into the simplicial_complexes. Is it something new?

AttributeError: 'module' object has no attribute 'RandomTwoSphere'

I tried with import but that does't work either.

2016-05-13 10:25:08 -0600 asked a question How to create random cubic planar graphs?

Hi,

I need to create random cubic planar graphs.

Do you know how can I do that?

Or alternatively, do you know a can create the dual of a random planar triangulation?

I saw that I can create triangulation using:

G = graphs.RandomTriangulation(n)

Bye and thanks

2016-05-11 07:38:37 -0600 asked a question How do I get the external face of a planar embedded graph?

First of all I am new to Sage and Python.

I need to get the external face a planar embedding and I immagined that it is always the first element returned by the function faces().

But in this example it seems to change. See the first and the second run.

Is it something about the function faces() or an error in this program?

print ("--- Create a graph")
G = Graph(sparse=True)
G.add_edge(1,2,"1-2")
G.add_edge(2,3,"2-3")
G.add_edge(3,4,"3-4")
G.add_edge(4,5,"4-5")
G.add_edge(5,1,"5-1")
G.add_edge(1,6,"1-6")
G.add_edge(2,10,"2-10")
G.add_edge(3,12,"3-12")
G.add_edge(4,11,"4-11")
G.add_edge(5,7,"5-7")
G.add_edge(6,7,"6-7")
G.add_edge(6,8,"6-8")
G.add_edge(8,10,"8-10")
G.add_edge(10,12,"10-12")
G.add_edge(12,11,"12-11")
G.add_edge(7,9,"7-9")
G.add_edge(8,9,"8-9")
G.add_edge(9,11,"9-11")

print ("--- Embed on a plane")
void = G.layout(layout = "planar", save_pos = True)

G.plot()

# Kempe reduction: for each loop remove an edge from faces <= F5
#
while len(G.faces()) > 2:

    print ("Number of faces: ", len(G.faces()))

    # Remove the external face. Is it always faces[0]???
    #
    faces = G.faces()
    externalFace = faces[0]
    facesWithoutTheExternalFace = copy(faces)
    facesWithoutTheExternalFace.remove(externalFace)
    print ("faces: ", faces)
    print ("externalFace: ", externalFace)
    print ("facesWithoutTheExternalFace: ", facesWithoutTheExternalFace)

    # Find the fist face [0] with len <= 5. It always exists: unavoidable set
    #
    faceToReduce = [x for x in facesWithoutTheExternalFace if len(x) <= 5][0]
    print ("Face <= 5: ", faceToReduce)

    # Find the first edge of the faceToReduce that is not on an edge on the external face
    #
    edgeToRemove = [x for x in faceToReduce if not x in externalFace][0]
    print ("edgeToRemove: ", edgeToRemove)

    verticesToRemove = G.get_vertices(edgeToRemove)
    print ("verticesToRemove ", verticesToRemove)

    G.delete_edge(edgeToRemove)
    neighborsOfTheFirstVertex = G.neighbors(verticesToRemove.keys()[0])
    neighborsOfTheSecondVertex = G.neighbors(verticesToRemove.keys()[1])
    print ("neighborsOfTheFirstVertex = ", neighborsOfTheFirstVertex)
    print ("neighborsOfTheSecondVertex = ", neighborsOfTheSecondVertex)
    G.delete_vertices(verticesToRemove)
    G.add_edge(neighborsOfTheFirstVertex[0], neighborsOfTheFirstVertex[1])
    G.add_edge(neighborsOfTheSecondVertex[0], neighborsOfTheSecondVertex[1])
    G.plot()
2016-05-11 07:38:37 -0600 asked a question How to find the first edge of a face (len <= 5) that is not an edge of the external face of a planar embedded graph

First of all I am new to sage and python programming.

In a planar graph I need to find an edge of a face (len <= 5) that is not an edge of the external face of a planar embedded graph.

Here is the code I'm trying.

G = Graph(sparse=True)
G.add_edge(1,2,"1-2")
G.add_edge(2,3,"2-3")
G.add_edge(3,4,"3-4")
G.add_edge(4,5,"4-5")
G.add_edge(5,1,"5-1")
G.add_edge(1,6,"1-6")
G.add_edge(2,10,"2-10")
G.add_edge(3,12,"3-12")
G.add_edge(4,11,"4-11")
G.add_edge(5,7,"5-7")
G.add_edge(6,7,"6-7")
G.add_edge(6,8,"6-8")
G.add_edge(8,10,"8-10")
G.add_edge(10,12,"10-12")
G.add_edge(12,11,"12-11")
G.add_edge(7,9,"7-9")
G.add_edge(8,9,"8-9")
G.add_edge(9,11,"9-11")

G.layout(layout = "planar", save_pos = True)
G.plot()

# Print all faces
#
faces = G.faces()
print ("Faces: ", faces)

# Find the fist face with len <= 5
#
faceToReduce = [x for x in faces if len(x) <= 5][0]
print ("Face <= 5: ", faceToReduce)

# Find the first edge of the faceToReduce that is not on an edge on the external face
#
externalFace = faces[0]
edgeTest = [x for x in faceToReduce if ... ???