Route inspection problem

49 views
Skip to first unread message

Jori Mäntysalo

unread,
Apr 1, 2018, 2:19:11 AM4/1/18
to sage-s...@googlegroups.com
I was walking at
https://kintulammi.fi/wp-content/uploads/Kintulammi_Opaskartta.jpg and
hence wondered if Sagemath has a function to solve
https://en.wikipedia.org/wiki/Route_inspection_problem . Didn't found any,
is it hidden with some other name or module?

--
Jori Mäntysalo

Dima Pasechnik

unread,
Apr 1, 2018, 7:10:48 AM4/1/18
to sage-support
this is also known as Chinese postman problem. There is a tutorial on doing it in networkx.
http://brooksandrew.github.io/simpleblog/articles/intro-to-graph-optimization-solving-cpp/

Jori Mäntysalo

unread,
Apr 2, 2018, 12:40:09 AM4/2/18
to sage-support
On Sun, 1 Apr 2018, Dima Pasechnik wrote:

> this is also known as Chinese postman problem. There is a tutorial on doing it in networkx.
> http://brooksandrew.github.io/simpleblog/articles/intro-to-graph-optimization-solving-cpp/

Duh. Was more complicated than I thank. Anyways, thanks; maybe I'll
implement that some day.

--
Jori Mäntysalo

HG

unread,
Apr 2, 2018, 10:57:27 AM4/2/18
to sage-support
I tried networkx, it works fine with python2 but I have a problem with edges in sagemath ?

edgelist.head(10)
TypeError: cannot do slice indexing on <class
 'pandas.core.indexes.range.RangeIndex'> with these indexers
[10] of <type 'sage.rings.integer.Integer'>
Is there a way getting it working ?

Dima Pasechnik

unread,
Apr 2, 2018, 4:12:27 PM4/2/18
to sage-support
an obvious way would be to modify the example so that it does not use pandas
(which seems to be only used to read data from csv files, something that's totally orthogonal to the task at hand)

slelievre

unread,
Apr 2, 2018, 6:58:09 PM4/2/18
to sage-support


Le lundi 2 avril 2018 16:57:27 UTC+2, HG a écrit :
> I tried networkx, it works fine with python2 but I have
> a problem with edges in sagemath ?
>
> edgelist.head(10)
> TypeError: cannot do slice indexing on <class
> 'pandas.core.indexes.range.RangeIndex'> with these indexers
> [10] of <type 'sage.rings.integer.Integer'>
> Is there a way getting it working ?

In Sage, you can try:

    edgelist.head(10r)

instead of

    edgelist.head(10)

where the r in 10r stands for "raw" and avoids the Python integer
10 to be preparsed into a Sage integer.

Henri Girard

unread,
Apr 3, 2018, 2:01:02 AM4/3/18
to sage-s...@googlegroups.com

Thanks, i must write it to each command but it works well

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Samuel Lelièvre

unread,
Apr 3, 2018, 2:44:29 AM4/3/18
to Sage-support
Or you can do edgelist.head(int(10))

slelievre

unread,
Apr 3, 2018, 2:52:44 AM4/3/18
to sage-support
Or you can turn off the Sage preparser.

    preparser(False)
    edgelist.head(10)


Le mardi 3 avril 2018 08:44:29 UTC+2, slelievre a écrit :
Or you can do edgelist.head(int(10))

Henri Girard

unread,
Apr 3, 2018, 3:51:24 AM4/3/18
to sage-s...@googlegroups.com

thanks preparser is ideal

--

Henri Girard

unread,
Apr 3, 2018, 3:52:40 AM4/3/18
to sage-s...@googlegroups.com

Do you think it's possible to draw fano's plane with networkx ?

I have been looking on internet but no answer yet

--

Samuel Lelièvre

unread,
Apr 3, 2018, 5:28:57 AM4/3/18
to Sage-support
Have you tried following the NetworkX tutorial?



2018-04-03 9:52 GMT+02:00 Henri Girard <henri....@gmail.com>:

Do you think it's possible to draw fano's plane with networkx ?

I have been looking on internet but no answer yet


Le 03/04/2018 à 08:52, slelievre a écrit :
Or you can turn off the Sage preparser.

    preparser(False)
    edgelist.head(10)


Le mardi 3 avril 2018 08:44:29 UTC+2, slelievre a écrit :
Or you can do edgelist.head(int(10))

2018-04-03 8:00 GMT+02:00 Henri Girard:

Thanks, i must write it to each command but it works well 

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscribe@googlegroups.com.

To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/E5OW4M4Frlw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support+unsubscribe@googlegroups.com.

Henri Girard

unread,
Apr 3, 2018, 5:58:50 AM4/3/18
to sage-s...@googlegroups.com

Yes... I am doing it. But Fano's plane seems to be quiet "special"...

To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages