davidp wrote:
>>> 4. In the second call, there should not be loops at each vertex.
>> Yes, there should be. It's a weighted graph with loops on the vertices,
>> since the laplacian has nonzero diagonal entries.
>>
>> Thanks,
>>
>> Jason
>
> The diagonal entries in the laplacian give the out_degrees of the
> corresponding vertices minus the weight of any loops.
I haven't seen a definition of the laplacian matrix for looped digraphs,
but sure, okay, I assume this is standard, then? I don't think the
laplacian_matrix function calculates this quantity for digraphs. This
might be a bug, then.
So is this laplacian matrix wrong?
sage: G = DiGraph({1:{1: 1, 2: 1}, 2:{1:1}})
sage: G
Looped digraph on 2 vertices
sage: G.laplacian_matrix()
[ 2 -1]
[-1 1]
Here is a
> simpler example showing that something is wrong.
>
> sage: G.laplacian_matrix()
>
> [ 2 -1 -1]
> [-1 2 -1]
> [-1 -1 2]
> sage: G = DiGraph({1:{2:1, 3:1}, 2:{1:1, 3:1}, 3:{1:1, 2:1}})
> sage: G.laplacian_matrix()
>
> [ 2 -1 -1]
> [-1 2 -1]
> [-1 -1 2]
> sage: G.show()
> sage: DiGraph(G.laplacian_matrix()).show()
>
> In this case, G is an ordinary triangle---no loops at vertices. Each
> vertex has out_degree 2.
>
> 1. G.show() is wrong since it misses some arrows.
Yes, I think this is a bug.
> 3. DiGraph(G.laplacian_matrix()).show() is also wrong because is
> missing arrowheads.
Yep, I agree.
> 2. DiGraph(G.laplacian_matrix()).show() is wrong because it displays
> loops at the vertices.
> 4. To clarify an earlier question: why aren't G.show() and DiGraph
> (G.laplacian_matrix()).show() the same?
> 4. To further complicate matters, I think that
>
> DiGraph(G.laplacian_matrix()).show(edge_labels=True)
I think the answer to questions 1, 4(a) and 4(b) are to clarify what
DiGraph(matrix) does. Just to clarify, here's the matrix in question:
sage: G = DiGraph({1:{2: 1}, 2:{1:1}})
sage: G.laplacian_matrix()
[ 1 -1]
[-1 1]
This is how I understand the intent of the DiGraph initialization
function: If there are negative numbers in the matrix, then the entries
of the matrix are treated as weights. If they are all nonnegative, then
the entries are treated as the numbers of edges. Since the diagonal
entries are nonzero, the digraph is given loops. Since the off-diagonal
entries are nonzero (and at least one is negative), the digraph is also
given two edges, with weights corresponding to the values of the entries.
I think the functionality is working exactly as intended. However, it
may be that Sage is trying too hard to be intelligent about guessing
what you want. Why do you expect that DiGraph(G.laplacian_matrix())
should give you back the same graph?
Jason
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---