across(g,X,Y) --- find all edges with one end in X and other end in Y. We require X and Y to be disjoint. If Y is omitted, then Y = V(g)-X. We do not require X U Y = V(g).
0001 function elist = across(g,X,Y) 0002 % across(g,X,Y) --- find all edges with one end in X and other end in Y. 0003 % We require X and Y to be disjoint. If Y is omitted, then Y = V(g)-X. 0004 % We do not require X U Y = V(g). 0005 0006 A = matrix(g); 0007 X = X(:); 0008 n = nv(g); 0009 0010 if nargin==2 0011 Y = setdiff(1:n,X); 0012 end 0013 0014 Y = Y(:); 0015 0016 B = A(X,Y); 0017 [i,j] = find(B); 0018 0019 ii = X(i); 0020 jj = Y(j); 0021 % make sure these are column vectors 0022 ii = ii(:); 0023 jj = jj(:); 0024 0025 elist = [ii,jj]; 0026