https://github.com/arbenson/higher-order-organization-matlab
Raw File
Tip revision: 3b5be032e625dc087cdf05832c86febaf527b14d authored by Austin Benson on 18 February 2019, 16:52:12 UTC
Fix bug with M1
Tip revision: 3b5be03
DirectionalBreakup.m
function [B, U, G] = DirectionalBreakup(A)
% DIRECTIONALBREAKUP returns the bidirectional, unidirectional, and
% undirected versions of the adjacency matrix A.
%
% [B, U, G] = DirectionalBreakup(A) returns
%   B: the bidirectional subgraph
%   U: the unidirectional subgraph
%   G: the undirected graph
%
%  Note that G = B + U

A(find(A)) = 1;
B = spones(A&A');  % bidirectional
U = A - B; % unidirectional
G = A | A';
back to top