Ask Your Question
0

How to make a graph from an latin square matrix ?

asked 9 years ago

vicarious gravatar image

updated 9 years ago

slelievre gravatar image

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

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
Preview: (hide)
link

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 ( 9 years ago )

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 ( 9 years ago )

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: 9 years ago

Seen: 485 times

Last updated: Dec 15 '15