Graph adjacency matrix to incidence matrix

Version (2.05 KB) by Ondrej
Conversion from graph adjacency matrix to incidence matrix.
Updated 6 Jul 2011

View License

Returns a sparse incidence matrix 'mInc' according to the adjacency matrix 'mAdj'. The edge ordering in the incidence matrix is according to the order of adjacent edges of vertices starting from the 1st vertex, i.e. first edges coincide with first vertex, next edges coincide with second vertex, etc.
If the graph is directed, the incidence matrix mInc contains -1s, indicating an "in-going" edge, and 1s indicating an "out-going" edge.
If the graph is undirected, the incidence matrix mInc contains only 1s.

Cite As

Ondrej (2024). Graph adjacency matrix to incidence matrix (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Undirected Graphs in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

new optional parameter: adj2inc(A,0)= directed, graph,adj2inc(A,1) = undirected graph

function renamed to adj2inc() + speed-up

faster check for matrix symmetry (minor speed-up)

warning identifier added + minor comments

Self-loops check added (Thanks to Wolfgang Schwanghart)

Major speed-up update thanks to Wolfgang Schwanghart

Error handling added + new comments