How to make a graph from an latin square matrix ?
As the question says I want to write a program that will make a graph from the given matrix ?
How can I do that in Sage?
As the question says I want to write a program that will make a graph from the given matrix ?
How can I do that in Sage?
I don't exactly know how a Latin square leads to a graph. But here is the graph documentation regarding adjacency matrices.
sage: M = Matrix([(0,1,0,0,1,1,0,0,0,0),(1,0,1,0,0,0,1,0,0,0), \
(0,1,0,1,0,0,0,1,0,0), (0,0,1,0,1,0,0,0,1,0),(1,0,0,1,0,0,0,0,0,1), \
(1,0,0,0,0,0,0,1,1,0), (0,1,0,0,0,0,0,0,1,1),(0,0,1,0,0,1,0,0,0,1), \
(0,0,0,1,0,1,1,0,0,0), (0,0,0,0,1,0,1,1,0,0)])
sage: M
[0 1 0 0 1 1 0 0 0 0]
[1 0 1 0 0 0 1 0 0 0]
[0 1 0 1 0 0 0 1 0 0]
[0 0 1 0 1 0 0 0 1 0]
[1 0 0 1 0 0 0 0 0 1]
[1 0 0 0 0 0 0 1 1 0]
[0 1 0 0 0 0 0 0 1 1]
[0 0 1 0 0 1 0 0 0 1]
[0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 1 0 1 1 0 0]
sage: G = Graph(M); G
Graph on 10 vertices
To a matrix with nonnegative integer entries, one could associate a graph, allowing multiple edges and loops. If the entries were not necessarily integer, one could think of a graph with weighted edges.
Yes, I thought of that, but usually one wouldn't say graph, but rather multigraph or weighted graph. Hopefully the original poster can clarify.
Asked: 9 years ago
Seen: 485 times
Last updated: Dec 15 '15