Cody

# Problem 475. Is this group simply connected?

Solution 68675

Submitted on 1 Apr 2012 by AMITAVA BISWAS
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% node_pairs = [8 9; 8 3]; tf = true; assert(isequal(isConnected(node_pairs),tf))

np = 2 3 2 1 a0 = 0 0 0 1 0 1 0 0 0 a = (2,1) 1 (1,2) 1 (3,2) 1 (2,3) 1 tf = (1,1) 1

2   Pass
%% node_pairs = [ 1 2; 2 3; 1 4; 3 4; 5 6 ]; tf = false; assert(isequal(isConnected(node_pairs),tf))

np = 1 2 2 3 1 4 3 4 5 6 a0 = 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 a = (2,1) 1 (4,1) 1 (1,2) 1 (3,2) 1 (2,3) 1 (4,3) 1 (1,4) 1 (3,4) 1 (6,5) 1 (5,6) 1 tf = All zero sparse: 1-by-1

3   Pass
%% node_pairs = [ 1 2; 2 3; 1 4; 3 4; 5 6; 6 2 ]; tf = true; assert(isequal(isConnected(node_pairs),tf))

np = 1 2 2 3 1 4 3 4 5 6 6 2 a0 = 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 a = (2,1) 1 (4,1) 1 (1,2) 1 (3,2) 1 (6,2) 1 (2,3) 1 (4,3) 1 (1,4) 1 (3,4) 1 (6,5) 1 (2,6) 1 (5,6) 1 tf = (1,1) 1

4   Pass
%% node_pairs = [ 1 2; 2 100]; tf = true; assert(isequal(isConnected(node_pairs),tf))

np = 1 2 2 3 a0 = 0 1 0 0 0 1 0 0 0 a = (2,1) 1 (1,2) 1 (3,2) 1 (2,3) 1 tf = (1,1) 1

5   Pass
%% node_pairs = [ 1 2; 50 100]; tf = false; assert(isequal(isConnected(node_pairs),tf))

np = 1 2 3 4 a0 = 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 a = (2,1) 1 (1,2) 1 (4,3) 1 (3,4) 1 tf = All zero sparse: 1-by-1

6   Pass
%% node_pairs = [ 4 17 ]; tf = true; assert(isequal(isConnected(node_pairs),tf))

np = 1 2 a0 = 0 1 0 0 a = (2,1) 1 (1,2) 1 tf = (1,1) 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!