Opened 4 years ago

Closed 4 years ago

#18149 closed defect (fixed)

Can add vertex to immutable graph once

Reported by: vbraun Owned by:
Priority: major Milestone: sage-6.6
Component: graph theory Keywords:
Cc: Merged in:
Authors: Nathann Cohen Reviewers: David Coudert
Report Upstream: N/A Work issues:
Branch: 01f2021 (Commits) Commit: 01f2021be46cba2b527cd09fc13f12e8668d168f
Dependencies: Stopgaps:

Description

sage: g = Graph({0:[1,2,3], 2:[4]}, immutable=True)
sage: g.add_vertex()
5
sage: g.add_vertex()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-8-ec8a05af84d7> in <module>()
----> 1 g.add_vertex()

/home/vbraun/Code/sage.git/local/lib/python2.7/site-packages/sage/graphs/generic_graph.pyc in add_vertex(self, name)
   8476 
   8477         """
-> 8478         return self._backend.add_vertex(name)
   8479 
   8480     def add_vertices(self, vertices):

/home/vbraun/Code/sage.git/src/sage/graphs/base/c_graph.pyx in sage.graphs.base.c_graph.CGraphBackend.add_vertex (build/cythonized/sage/graphs/base/c_graph.c:13807)()
   1533             retval = name
   1534 
-> 1535         check_vertex(name,
   1536                      self.vertex_ints,
   1537                      self.vertex_labels,

/home/vbraun/Code/sage.git/src/sage/graphs/base/c_graph.pyx in sage.graphs.base.c_graph.check_vertex (build/cythonized/sage/graphs/base/c_graph.c:11994)()
   1199     u_int = bitset_first_in_complement(G.active_vertices)
   1200     if u_int == -1:
-> 1201         G.realloc(2*G.active_vertices.size)
   1202         if reverse:
   1203             G_rev.realloc(2*G_rev.active_vertices.size)

/home/vbraun/Code/sage.git/src/sage/graphs/base/c_graph.pyx in sage.graphs.base.c_graph.CGraph.realloc (build/cythonized/sage/graphs/base/c_graph.c:9528)()
    721             30
    722         """
--> 723         raise NotImplementedError()
    724 
    725     ###################################

NotImplementedError: 

Change History (6)

comment:1 Changed 4 years ago by ncohen

O_o

comment:2 Changed 4 years ago by ncohen

  • Authors set to Nathann Cohen
  • Branch set to public/18149
  • Status changed from new to needs_review

Sorry about that. Needs review.

Nathann

comment:3 Changed 4 years ago by git

  • Commit set to 07e61cb7f7a7f3fd0b225d18d547fbb5bcf7e3e0

Branch pushed to git repo; I updated commit sha1. New commits:

2f2fbd4trac #18137: Add new centrality module
6dfcbc3Trac 18137: some simplification + tiny doc changes
f21ae32trac #18137: Review
eaa6a3etrac #18137: ... -> ....:
07e61cbtrac #18149: Can add vertex to immutable graph once

comment:4 Changed 4 years ago by git

  • Commit changed from 07e61cb7f7a7f3fd0b225d18d547fbb5bcf7e3e0 to 01f2021be46cba2b527cd09fc13f12e8668d168f

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

01f2021trac #18149: Can add vertex to immutable graph once

comment:5 Changed 4 years ago by dcoudert

  • Reviewers set to David Coudert
  • Status changed from needs_review to positive_review

In fact you fixed 2 issues. Now we have:

sage: g = Graph({0:[1,2,3], 2:[4]}, immutable=True)
sage: g.add_vertex()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: an integer is required
sage: g.add_vertex(6)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
...
ValueError: Thou shalt not add a vertex to an immutable graph

For me the patch is OK, although this "Thou shalt not" is weird.

David.

comment:6 Changed 4 years ago by vbraun

  • Branch changed from public/18149 to 01f2021be46cba2b527cd09fc13f12e8668d168f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.