Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fill Adjecency matrix

Subject: Fill Adjecency matrix

From: Sjoerd

Date: 24 Jul, 2013 14:50:09

Message: 1 of 3

Hai,

I want to fill an adjacency matrix for a undirected graph theory concept. The sum of every row must be equal and the matrix must be symmetric. No self connections must be possible, so the diagonal must be zero.

Current setup is as follows, but this renders too often to an impossible situation;
- nodes_eager = list of nodes that do not match the desired total
- nodes_breath = list of nodes with minimum of friends
=> find self (random node from nodes_breath)
- nodes_shotlist = nodes_breath (whem numel() > 1) else nodes_eager
=> remove self and all existing edges from node_shortlist
=> find friend (random node from nodesshortlist)
=> create friendship AM(self, friend)=1 and AM(friend, self)=1

It happens to often that the nodes_shortlist is empty, meaning that there are no possibilities left. In example, when sum must be three;
AM =
     0 1 0 1 1
     1 0 0 1 1
     0 0 0 1 1 <==
     1 1 1 0 0
     1 1 1 0 0

Subject: Fill Adjecency matrix

From: Steven_Lord

Date: 24 Jul, 2013 17:30:26

Message: 2 of 3



"Sjoerd " <sjjhuisman@hotmail.com> wrote in message
news:ksopj1$e41$1@newscl01ah.mathworks.com...
> Hai,
>
> I want to fill an adjacency matrix for a undirected graph theory concept.
> The sum of every row must be equal and the matrix must be symmetric. No
> self connections must be possible, so the diagonal must be zero.

*snip*

So you want a regular graph.

http://en.wikipedia.org/wiki/Regular_graph

Reference 4 appears to contain an algorithm that you may be able to
implement. Google also found this paper that may be of interest to you as
well:

http://www.sciencedirect.com/science/article/pii/030439759090164D

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Fill Adjecency matrix

From: Sjoerd

Date: 26 Jul, 2013 09:35:07

Message: 3 of 3

Thanks for giving me that name!

A script already has been made;
http://www.mathworks.com/matlabcentral/fileexchange/29786-random-regular-generator/content/randRegGraph/createRandRegGraph.m

Best,
Sjoerd

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us