Ticket #11942: trac_11942.patch

File trac_11942.patch, 1.8 KB (added by ncohen, 5 years ago)
  • sage/graphs/base/c_graph.pyx

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1319210935 -7200
    # Node ID 19f096fe24a2280948e4d4486341f9e81744f177
    # Parent  d740726a92bc0eef8e372e0a59c37b6cdf0a84b0
    trac #11942 -- segfault on Graph().connected_component_containing_vertex('')
    
    diff --git a/sage/graphs/base/c_graph.pyx b/sage/graphs/base/c_graph.pyx
    a b  
    33183318            sage: g = graphs.PetersenGraph()
    33193319            sage: list(g.breadth_first_search(0))
    33203320            [0, 1, 4, 5, 2, 6, 3, 9, 7, 8]
     3321
     3322        TEST:
     3323
     3324        A vertex which does not belong to the graph::
     3325
     3326            sage: list(g.breadth_first_search(-9))
     3327            Traceback (most recent call last):
     3328            ...
     3329            ValueError: The given vertex is not an element of the graph !
     3330
     3331        An empty graph::
     3332           
     3333            sage: list(Graph().breadth_first_search(''))
     3334            Traceback (most recent call last):
     3335            ...
     3336            ValueError: The given vertex is not an element of the graph !
    33213337        """
    33223338        self.graph = graph
    33233339        self.direction = direction
     
    33253341        bitset_init(self.seen, (<CGraph>self.graph._cg).active_vertices.size)
    33263342        bitset_set_first_n(self.seen, 0)
    33273343
    3328         self.stack = [get_vertex(v,
     3344        cdef int v_id = get_vertex(v,
    33293345                                 self.graph.vertex_ints,
    33303346                                 self.graph.vertex_labels,
    3331                                  self.graph._cg)]
     3347                                 self.graph._cg)
     3348
     3349        if v_id == -1:
     3350            raise ValueError("The given vertex is not an element of the graph !")
     3351
     3352        self.stack = [v_id]
    33323353
    33333354        if not self.graph.directed:
    33343355            ignore_direction = False