Ask Your Question
0

How to make a graph from an latin square matrix ?

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

vicarious gravatar image

updated 2015-12-14 21:40:33 -0500

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-12-15 08:06:25 -0500

kcrisman gravatar image

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
edit flag offensive delete link 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.

slelievre gravatar imageslelievre ( 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.

kcrisman gravatar imagekcrisman ( 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

Question Tools

1 follower

Stats

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

Seen: 75 times

Last updated: Dec 15 '15