Sagemath saving results

46 views
Skip to first unread message

Mauro Weber

unread,
May 5, 2020, 6:29:41 PM5/5/20
to sage-support

Hello, I’m using Sagemath to filter some specific graphs from the general graphs using these codes: 


“I = graphs(n)

for G in I:

if G.is_tree():

if (G.cartesian_product(G)).matching(value_only = True) == n*n/2:

G.show()”

The problem is that there are a large number of graphs to filter particularly when the number of vertices is greater than 16. This takes a long time so. I was wondering if it is possible to create a library with those graphs I received from the code. Then every time I need to use those graphs I can get them from the library and don’t need to run the code all over again.


Vincent Delecroix

unread,
May 7, 2020, 6:38:23 AM5/7/20
to sage-s...@googlegroups.com
Le 06/05/2020 à 00:10, Mauro Weber a écrit :
> for G in I:
>
> if G.is_tree():

If you want to iterate over trees don't filter them by generating all
graphs. This is a huge waste of time

# graphs(n) "=" 2^(n^2) / n!
# trees(n) "=" Catalan(n)

Trees are easy to generate up to isomorphism.

Vincent

Dima Pasechnik

unread,
May 7, 2020, 6:57:34 AM5/7/20
to sage-support
On Thu, May 7, 2020 at 11:38 AM Vincent Delecroix
specifically, see
http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/trees.html

>
> Vincent
>
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/f2feda5e-4f55-6c05-1d55-9ba66d480f6f%40gmail.com.
Reply all
Reply to author
Forward
0 new messages