Ticket #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: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | Adam Webb |
| Authors: | Nathann Cohen | Merged in: | sage-4.3.alpha1 |
| Dependencies: | Stopgaps: |
Description
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
Change History
comment:1 Changed 4 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:3 Changed 4 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 4 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
comment:7 Changed 4 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 4 years ago by mhansen
- Status changed from positive_review to closed
- Report Upstream set to N/A
- Resolution set to fixed
- Merged in set to sage-4.3.alpha1
- Authors set to Nathann Cohen
comment:10 Changed 3 years ago by mvngu
- Summary changed from [with patch, positive review] The whole world in a graph to The whole world in a graph

