Opened 11 years ago

Closed 11 years ago

#7380 closed defect (worksforme)

Replace Graph.vertices() by Graph.vertex_iterator when possible

Reported by: ncohen Owned by: rlm
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: graph theory Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

As the title says, there are many places where Graph.vertices() is used when Graph.vertex_iterator ( or even self ) would be better. The same goes for edges.

Nathann

Change History (7)

comment:1 Changed 11 years ago by ncohen

  • Milestone changed from sage-4.3.4 to sage-duplicate/invalid/wontfix
  • Report Upstream set to N/A
  • Resolution set to wontfix
  • Status changed from new to closed

Useless.

comment:2 Changed 11 years ago by mvngu

Read this section before closing tickets. Can you explain why you want to close this ticket?

comment:3 follow-up: Changed 11 years ago by ncohen

Well, as I created it I thought it would not be so bad to close it too ;

The thing is that I do not feel anymore that this should be done, or just useful in any way. It would just slow down most functions as creating an iterator has no real sense when the whole set is already stored in memory, and it would make the code harder to read for no real purpose :p

Nathann

comment:4 in reply to: ↑ 3 Changed 11 years ago by mvngu

Replying to ncohen:

Well, as I created it I thought it would not be so bad to close it too ;

As long as you provide a good reason to close the ticket. Don't just close a ticket without any good reasons.

comment:5 Changed 11 years ago by ylchapuy

Sorry for commenting a closed ticket, but...

If I look at the docstring for vertices I see (in the default case):

return sorted(list(self.vertex_iterator()))

A new list is created, doubling the memory needed, and this list is sorted which might take time too.

I still think it might make sense to replace vertices with vertex_iterator when possible.

comment:6 follow-up: Changed 11 years ago by ncohen

  • Resolution wontfix deleted
  • Status changed from closed to new

oops... Well, if "vertices()" is calling vertex_iterator, plus sorts it, then I said nothing...

comment:7 in reply to: ↑ 6 Changed 11 years ago by mvngu

  • Resolution set to worksforme
  • Status changed from new to closed

Replying to ncohen:

oops... Well, if "vertices()" is calling vertex_iterator, plus sorts it, then I said nothing...

Do not reopen this ticket. Let it die and open a new ticket.

Note: See TracTickets for help on using tickets.