graph_tool.spectral.adjacency() returns the transpose of the adjacency of a directed graph
The function graph_tool.spectral.adjacency<http://graph-tool.skewed.de/static/doc/spectral.html?highlight=adjacency#graph_tool.spectral.adjacency> returns transpose of the adjacency matrix of a directed graph that is commonly used. Is this intentional? A misinterpretation of column-major versus row-major on my part? Compare a few standard examples: http://en.wikipedia.org/wiki/Adjacency_matrix#Examples http://www.math.cornell.edu/~mec/Winter2009/RalucaRemus/Lecture2/lecture2.ht... with the output of gt.adjacency(): import graph_tool.all as gt g = gt.Graph() v0 = g.add_vertex() v1 = g.add_vertex() e01 = g.add_edge(v0,v1) A = gt.adjacency(g) A.todense() [e for e in g.edges()] ## -- End pasted text -- Out[2]: [<Edge object with source '0' and target '1' at 0x11fb10d60>] A.todense() Out[3]: matrix([[ 0., 0.], [ 1., 0.]]) A in this case is most commonly defined as [[0, 1], [0, 0]]
On 31.05.2015 18:24, Smith, Steven - 1004 - MITLL wrote:
The function graph_tool.spectral.adjacency <http://graph-tool.skewed.de/static/doc/spectral.html?highlight=adjacency#graph_tool.spectral.adjacency> returns transpose of the adjacency matrix of a directed graph that is commonly used. Is this intentional? A misinterpretation of column-major versus row-major on my part?
It is true that most software and some websites use the more intuitive definition that you were expecting. However a large part of the theoretical literature uses the transposed definition, since it can be more convenient mathematically. See for instance Mark Newman's book. In any case, this an unimportant issue. A matrix transpose can be obtained trivially in numpy. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
It is true that most software and some websites use the more intuitive definition that you were expecting. However a large part of the theoretical literature uses the transposed definition, since it can be more convenient mathematically. See for instance Mark Newman's book. I know — I use Godsil and Royle, who use the “correct” untransposed version in Algebraic Graph Theory ;o) Because you cite the Wikipedia definition in your excellent documentation, I’d suggest documenting the convention you use explicitly, which is the transpose of Wiki’s (current) definition.
On 31.05.2015 19:16, Smith, Steven - 1004 - MITLL wrote:
Because you cite the Wikipedia definition in your excellent documentation, I’d suggest documenting the convention you use explicitly, which is the transpose of Wiki’s (current) definition.
That makes sense. I also noticed that the documentation of the other spectral functions were inconsistent with this definition. I have fixed it now: https://graph-tool.skewed.de/static/doc/dev/spectral.html#graph_tool.spectra... Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Smith, Steven - 1004 - MITLL -
Tiago de Paula Peixoto