Ticket #9211: trac-9211-add_padding_to_graphs.patch

File trac-9211-add_padding_to_graphs.patch, 1.9 KB (added by ppurka, 10 years ago)

( Add additional padding to graphs ) Apply to devel/sage

  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User P Purkayastha <ppurka@gmail.com>
    # Date 1318326236 -28800
    # Node ID 035c51ea8b63e54a53ad2568a8db876d8ced4ad9
    # Parent  b01c2facbe51d941d95a8b5ca8169d0fd8f5f45a
    # trac #9211: Add additional padding to graphs
    
    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    1288312883
    1288412884            sage: H = digraphs.ButterflyGraph(1)
    1288512885            sage: H.layout_extend_randomly({('0',0): (0,0), ('1',1): (1,1)})
    12886             {('1', 1): (1, 1),
    12887              ('0', 0): (0, 0),
    12888              ('1', 0): [0.111..., 0.514...],
    12889              ('0', 1): [0.0446..., 0.332...]}
     12886            {('1', 1): (1, 1), ('0', 0): (0, 0), ('1', 0): [0.033..., 0.517...], ('0', 1): [-0.046..., 0.298...]}
    1289012887        """
    1289112888        assert dim == 2 # 3d not yet implemented
    1289212889        from sage.misc.randstate import current_randstate
     
    1307213069            sage: Graph()._layout_bounding_box( {} )
    1307313070            [-1, 1, -1, 1]
    1307413071            sage: Graph()._layout_bounding_box( {0: [3,5], 1: [2,7], 2: [-4,2] } )
    13075             [-4, 3, 2, 7]
     13072            [-22/5, 17/5, 13/10, 77/10]
    1307613073            sage: Graph()._layout_bounding_box( {0: [3,5], 1: [3.00000000001,4.999999999999999] } )
    13077             [2, 4.00000000001000, 4.00000000000000, 6]
     13074            [1.59999999999900, 4.40000000001100, 3.40000000000000, 33/5]
     13075            sage: Graph()._layout_bounding_box( {0: [1,0.02], 1: [2,0.01] } )
     13076            [4/5, 11/5, 0.00800000000000000, 0.0220000000000000]
    1307813077        """
    1307913078        xs = [pos[v][0] for v in pos]
    1308013079        ys = [pos[v][1] for v in pos]
     
    1309713096            ymax += 1
    1309813097            ymin -= 1
    1309913098
    13100         return [xmin, xmax, ymin, ymax]
     13099        xeps = max([abs(xmin), abs(xmax)])/10
     13100        yeps = max([abs(ymin), abs(ymax)])/10
     13101        return [xmin-xeps, xmax+xeps, ymin-yeps, ymax+yeps]
    1310113102
    1310213103
    1310313104