Ask Your Question

# 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?

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

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

more

## Comments

1

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.

( 2015-12-15 10:15:00 -0500 )edit

Yes, I thought of that, but usually one wouldn't say graph, but rather multigraph or weighted graph. Hopefully the original poster can clarify.

( 2015-12-15 11:02:25 -0500 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2015-12-14 13:20:10 -0500

Seen: 79 times

Last updated: Dec 15 '15