Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6813 closed enhancement (fixed)

The whole world in a graph

Reported by: ncohen Owned by: rlm
Priority: major Milestone: sage-4.3
Component: graph theory Keywords:
Cc: Merged in: sage-4.3.alpha1
Authors: Nathann Cohen Reviewers: Adam Webb
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

see http://groups.google.com/group/sage-devel/browse_thread/thread/25e57b8421c0ae9c/5ed13d13bc41b370#5ed13d13bc41b370

This patch adds a function WorldMap? to graph_generators.py, which lets the user load the graph in which vertices are countries and links denote a shared boundary between two of them. The data I used to build this comes from The Cia Factbook ( mentionned in the docstring )

To use it, you need to apply the patch, but also to move the file graph_world.sobj to SAGE_ROOT/data/graphs/

Thank you for your help ! :-)

Attachments (3)

graph_world.sobj (9.4 KB) - added by ncohen 10 years ago.
worldmap.patch (2.5 KB) - added by ncohen 10 years ago.
6813-worldmap.patch (2.4 KB) - added by awebb 10 years ago.
applies to sage-4.1.2.rc0

Download all attachments as: .zip

Change History (13)

Changed 10 years ago by ncohen

Changed 10 years ago by ncohen

comment:1 Changed 10 years ago by jason

  • Summary changed from [with patch, needs review] The whole world in a graph to [with patch, needs work] The whole world in a graph

I get errors. At the bottom, I copy the md5 digest to check my download:

sage: g=graphs.WorldMap() 
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)

/home/jason/.sage/temp/littleone/13542/_home_jason__sage_init_sage_0.py in <module>()

/home/jason/sage/local/lib/python2.6/site-packages/sage/graphs/graph_generators.pyc in WorldMap(self)
   2985         from sage.structure.sage_object import load
   2986         from sage.misc.misc import SAGE_DATA
-> 2987         return load(SAGE_DATA+"graphs/graph_world.sobj")
   2988 
   2989 ################################################################################

/home/jason/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.load (sage/structure/sage_object.c:7173)()

/home/jason/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.loads (sage/structure/sage_object.c:8769)()

UnpicklingError: invalid load key, '<'.
sage: load sage.misc.misc.SAGE_DATA + 'graphs/graph_world.sobj'
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)

/home/jason/.sage/temp/littleone/13542/_home_jason__sage_init_sage_0.py in <module>()

/home/jason/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.load (sage/structure/sage_object.c:7173)()

/home/jason/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.loads (sage/structure/sage_object.c:8769)()

UnpicklingError: invalid load key, '<'.
sage: os.listdir(sage.misc.misc.SAGE_DATA + 'graphs/')
['graph_world.sobj', 'graphs.db']
sage: import md5 
sage: md5.md5(sage.misc.misc.SAGE_DATA + 'graphs/graph_world.sobj').hexdigest()
'0ae838b9de40596827c6e674b733f489'

comment:2 Changed 10 years ago by jason

that was with 4.1.2.alpha2

comment:3 Changed 10 years ago by ncohen

  • Summary changed from [with patch, needs work] The whole world in a graph to [with patch, needs review] The whole world in a graph

I get a totally different checksum..... Good job noticing it !!!

I just retried to load the graph with a version of the file graph_world downloaded from the TRAC server and it worked for me. My checksum is the following :

sage: sage: g=graphs.WorldMap() 
sage: g
Graph on 251 vertices
sage: import md5 
sage: sage: md5.md5(sage.misc.misc.SAGE_DATA + 'graphs/graph_world.sobj').hexdigest()
'805fdf0227e964c41f3892c6979f62dc'

As I suspect it may come from some weird encoding, here is a .rar version of the file : http://www-sop.inria.fr/members/Nathann.Cohen/world.rar

I also copied the file on sagemath in the directory as ~/ncohen/graph_world.sobj

On my machine

~$ md5sum  /usr/local/sage/data/graphs/graph_world.sobj
438bc195a9486caebeb47442ff8b8d8c  /usr/local/sage/data/graphs/graph_world.sobj

On sagemath

ncohen@sage:~$ md5sum graph_world.sobj 
438bc195a9486caebeb47442ff8b8d8c  graph_world.sobj

Could you check if this version works, and if the checksum is correct ? Thank you !!!

Nathann

comment:4 Changed 10 years ago by awebb

I get the same checksum as you do.

{{{$ md5sum data/graphs/graph_world.sobj 438bc195a9486caebeb47442ff8b8d8c data/graphs/graph_world.sobj }}} I was unable to apply the patch to sage-4.1.2.rc0. I guess a rebase is needed. Once I had the patch applied there were some warnings when I tried to do sage -docbuild. I made some changes to fix that. Specifically, I changed the reference so that it was similar to other ones on the same page. I hope that it is still fine. Otherwise, if you are happy with my small changes than I would give it a positive review.

Adam

Changed 10 years ago by awebb

applies to sage-4.1.2.rc0

comment:5 Changed 10 years ago by awebb

  • Reviewers set to Adam Webb

comment:6 Changed 10 years ago by ncohen

These changes are perfect for me ! Thank for your help :-)

comment:7 Changed 10 years ago by awebb

  • Status changed from needs_review to positive_review
  • Summary changed from [with patch, needs review] The whole world in a graph to [with patch, positive review] The whole world in a graph

comment:8 Changed 10 years ago by mhansen

  • Authors set to Nathann Cohen
  • Merged in set to sage-4.3.alpha1
  • Report Upstream set to N/A
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:9 Changed 10 years ago by mhansen

I had to add the .sobj file to the graphs-20070722 spkg.

comment:10 Changed 10 years ago by mvngu

  • Summary changed from [with patch, positive review] The whole world in a graph to The whole world in a graph
Note: See TracTickets for help on using tickets.