Graph([('A',1)]).adjacency_matrix() raises exception

20 views
Skip to first unread message

Georgi Guninski

unread,
Jun 26, 2023, 11:20:50 AM6/26/23
to sage-...@googlegroups.com
In both 9.6 and https://sagecell.sagemath.org/

Graph([('A',1)]).adjacency_matrix()

raises exception

TypeError: '<' not supported between instances of 'int' and 'str'

John H Palmieri

unread,
Jun 26, 2023, 2:32:56 PM6/26/23
to sage-devel
Please read the help message for adjaceny_matrix.

    g = Graph([('A',1)])
    g.adjacency_matrix?

prints, among other things:

   * "vertices" -- list (default: "None"); the ordering of the
     vertices defining how they should appear in the matrix. By
     default, the ordering given by "GenericGraph.vertices()" with
     "sort=True" is used. If the vertices are not comparable, the
     keyword "vertices" must be used to specify an ordering, or a
     TypeError exception will be raised.

Your vertices are not comparable.

John H Palmieri

unread,
Jun 26, 2023, 2:36:03 PM6/26/23
to sage-devel
By the way, I see this error message:

    TypeError: Vertex labels are not comparable. You must specify an ordering using parameter ``vertices``

Indeed, this works:

    g.adjacency_matrix(vertices=['A', 1])
Reply all
Reply to author
Forward
0 new messages