ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 02 May 2020 17:01:38 +0200Graph indexed from zerohttps://ask.sagemath.org/question/51211/graph-indexed-from-zero/ How to change vertices of a graph to that are indexed from 0?
In Mathematica: ChangeVertices.
We can change it to the adjacency matrix A and from A to the graph. A faster solution?
Ho to get a permutation of vertices?SYLASat, 02 May 2020 17:01:38 +0200https://ask.sagemath.org/question/51211/[Sage vs Python] Matrix indexing and list standardshttps://ask.sagemath.org/question/48802/sage-vs-python-matrix-indexing-and-list-standards/Hello, Sage Community!
Since I learned Sage, I have used the notation `A[i][j]` (which obviously came from my previous experience with Python lists) to access the (i+1, j+1)-th element of a matrix. However, I discovered a few weeks ago that I can also use the syntax `A[i,j]`. I am wondering which of these two ways of matrix indexing is preferred in Sage?
My tests using `timeit` indicate that the second syntax is faster than the first one by a factor of 500. So I suppose it to be simply natural that the fastest syntax is preferred. However, why to deviate from the list syntax? After all, lists and lists of lists are (in some sense) arrays, too.
On the other hand, talking about lists, there is the syntax `[1..10]`, which creates the list
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Why is this the case when Python would ignore the 10? For example, `range(1, 10)` is equivalent to
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Even `srange(1, 10)` creates the same list, but with Sage `Integer`s, instead of Python's `int`s. Is there any good reason for having `[1..10]`be equivalent to `srange(1, 11)`?
Thanks in advance for your answers!dsejasMon, 18 Nov 2019 23:18:18 +0100https://ask.sagemath.org/question/48802/