about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/graph/connected_graph.m
blob: 612393ea7926eadd76700a003c8e1c41583ada42 (plain)
1
2
3
4
5
6
7
8
9
function b = connected(adj_mat, directed)
%
% b = connected(adj_mat).
% Returns true iff the graph is connected.

n = length(adj_mat);
start = 1;
[d, pre] = dfs(adj_mat, start, directed);
b = (length(pre) == n);