Rank: 2806 based on 25 downloads (last 30 days) and 1 file submitted
photo

Ondrej

E-mail

Personal Profile:

Professional Interests:

 

Watch this Author's files

 

Files Posted by Ondrej
Updated   File Tags Downloads
(last 30 days)
Comments Rating
10 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej adjacency, incidence, graph 25 4
  • 5.0
5.0 | 2 ratings
Comments and Ratings by Ondrej View all
Updated File Comments Rating
15 Oct 2009 gridcolor Change color of grid lines without changing color of axis labels or box Author: Sebastian Hölz

I have problems with zooming. When I use gridcolor I can't zoom the plots in figure, instead the whole box is getting smaller and smaller.

15 Oct 2009 gridcolor Change color of grid lines without changing color of axis labels or box Author: Sebastian Hölz

04 Sep 2009 Eigenshuffle Consistently sorted eigenvalue and eigenvector sequences Author: John D'Errico

I thought so, that it couldn't be any harder than eigenvalues, but then I looked here
http://www.math.uu.nl/publications/preprints/1180.ps

Actually the code there seems to work pretty well. So schurly, no need to reinvent schurshuffle

03 Sep 2009 Eigenshuffle Consistently sorted eigenvalue and eigenvector sequences Author: John D'Errico

Is it possible to write the same functionality but for schur decomposition? Schur function in matlab returns the eigenvalues on diagonal in same order as eig function..which is not always nice. Thanks.

10 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej

I just uploaded an updated version with self-loops checks and I also added an example. However, I left the conversion to sparse matrix unchanged, because I believe that in most cases the adjency matrix will contain "enough" zeros to have the computation more efficient.
btw. I didn't use spdiags because according to my simulations, it is slower than normal diag (and since I use it only for a check, it shouldn't last long).

P.S. Thank you once again Wolfgang for all those hints.

Comments and Ratings on Ondrej's Files View all
Updated File Comment by Comments Rating
10 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej Ondrej

I just uploaded an updated version with self-loops checks and I also added an example. However, I left the conversion to sparse matrix unchanged, because I believe that in most cases the adjency matrix will contain "enough" zeros to have the computation more efficient.
btw. I didn't use spdiags because according to my simulations, it is slower than normal diag (and since I use it only for a check, it shouldn't last long).

P.S. Thank you once again Wolfgang for all those hints.

10 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej Schwanghart, Wolfgang

Now that's much better and much faster. Two minor things that can still be improved. First, if the adjacency matrix is supplied as full matrix, you don't really need to convert it to sparse. It should work without converting. Returning the incidence matrix as sparse however, is always a good idea since it likely contains many more zeros than the adjacency matrix.

Second, the function fails in case of nonzeros on the main diagonal. While this may rarely happen (except when your graph has 1-cycles), it may be worth an a-priori check using the function spdiags.

By the way, it might be nicer to write ~issparse(mAdj) instead of (issparse(mAdj)==0), but that's really not so important. And... providing a minimal example in the help block is always good.

Thanks for the update.

08 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej Ondrej

Well, thank you for pointing out those "bugs". You are right about all you said.Actually I already planned to change it to some more efficient algorithm without loops, but as I can see you basically already solved it:-). So thank you. I will soon really simplify the code and post it here.

08 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej Schwanghart, Wolfgang

At first sight, this function is quite good. It has a reasonable help, error checks and quite a few comments in the code. Yet, regarding its computational efficiency, there is a serious short-coming. It is heavily looped, both when extracting edges from the adjacency matrix and when building the incidence matrix. This makes the function slow and makes it even slower when you have a sparse adjacency matrix as input. You can easily vectorize this function using the find function with two outputs. Following lines have been written for a conversion from a (sparse) adjacency matrix B to a sparse incidence matrix A.

siz = size(B);
if siz(1)~=siz(2);
    error('B must be square');
end

nrknots = siz(1);
nredges = nnz(B);
[IXknots1,IXknots2] = find(B);
sones = ones(nredges,1);
IXedges = (1:nredges)';

A = sparse([IXedges; IXedges],...
             [IXknots1; IXknots2],...
             [-sones; sones],...
             nredges,nrknots);

Perhaps you have the time to modify your function so that it can handle sparse matrices efficiently. Right now, the function is very inefficient and hence I rate it with only one star. Yet, I am happy to change my rating when the above mentioned problems are fixed.

Top Tags Applied by Ondrej
adjacency, graph, incidence
Files Tagged by Ondrej
Updated   File Tags Downloads
(last 30 days)
Comments Rating
10 Jul 2009 Graph adjacency matrix to incidence matrix Conversion from graph adjacency matrix to incidence matrix. Author: Ondrej adjacency, incidence, graph 25 4
  • 5.0
5.0 | 2 ratings
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com