File: safe_edgecut.m

package info (click to toggle)
suitesparse 1%3A5.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 138,928 kB
  • sloc: ansic: 389,614; cpp: 24,213; makefile: 5,965; fortran: 1,927; java: 1,808; csh: 1,750; ruby: 725; sh: 226; perl: 225; python: 209; sed: 164; awk: 60
file content (37 lines) | stat: -rw-r--r-- 1,271 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function partition = safe_edgecut(G,O,A)
%SAFE_EDGECUT sanitizes and computes an edge cut of a graph.
%   safe_edgecut sanitizes the graph adjacency matrix by removing its diagonal
%   and attempting to form a symmetric matrix from the input. After
%   sanitization, an edge cut of the graph is computed and returned as a binary
%   array.
%
%   partition = SAFE_EDGECUT(G) assumes default options and no vertex weights
%   (i.e. all vertex weights are 1). The partition is returned as a binary
%   array.
%
%   partition = SAFE_EDGECUT(G, O) uses the options struct to define how the
%   edge cut algorithms are run.
%
%   partition = SAFE_EDGECUT(G, O, A) initializes the graph with vertex weights
%   provided in the array A such that A(i) is the vertex weight of vertex i.
%
%   Example:
%       Prob = ssget('HB/494_bus'); A = Prob.A;
%       part = safe_edgecut(A);
%       perm = [find(part) find(1-part)];
%       A_perm = A(perm, perm); % Permute the matrix
%       spy(A_perm);
%
%   See also EDGECUT, EDGECUT_OPTIONS.

%   Copyright (c) 2018, N. Yeralan, S. Kolodziej, T. Davis, W. Hager

G_safe = sanitize(G);

if nargin == 1
    partition = edgecut(G_safe);
elseif nargin == 2
    partition = edgecut(G_safe,O);
else
    partition = edgecut(G_safe,O,A);
end