View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

2.0 | 1 rating Rate this file 6 Downloads (last 30 days) File Size: 2.2 KB File ID: #30862 Version: 1.6



Ondrej (view profile)


26 Mar 2011 (Updated )

Conversion from graph incidence matrix to adjacency matrix.

| Watch this File

File Information

Returns a sparse adjacency matrix 'mAdj' according to the incidence matrix 'mInc'. The rows in the incidence matrix must represent the edges, while the columns the vertices.
Function can handle directed graphs with incidence matrix containing -1s, indicating an "in-going" edge, and 1s indicating an "out-going" edge.

MATLAB release MATLAB 7.9 (R2009b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
31 May 2011 Ondrej

Ondrej (view profile)

I don't quite understand what kind of problem you had, Muhammad. The function should return normal adjacency matrix and not adjacency list. Could you please provide some example and the expected result you would want? And of course, if you noticed some incorrect behaviour, I would gladly fix it.

Comment only
23 Apr 2011 Muhammad Shafique

It was of great help. Thanks! Being occasional user of Matlab, however, the ideal output for me would have been a matrix, or at least some properly delimited list. I had a hard time converting the output into proper adjacency matrix I needed. This was due to different number of spaces before, within, and after each element. It would be great if the output is in the form 1,2,3 with no spaces anywhere. I used Matlab7.10 (R2010a).

31 Mar 2011 1.1

faster check of the input matrix

13 Dec 2012 1.3

Major code optimization (Thanks to Andreas Gunnel for inspiration)

24 Feb 2016 1.4

handled case when the input matrix is zero

24 Feb 2016 1.5

input consistency check modified

25 Feb 2016 1.6

checks for correct input added (Thanks to Kaif Agbaje)

Contact us