Cody

# Problem 2732. Construct a precedence graph from a code segment

Solution 1116964

Submitted on 7 Feb 2017
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   Fail
C = {'a=1;' 'b=1;' 'c=a+b;' 'c=c+1;'}; mat = [0 0 1 1; 0 0 1 1; 0 0 0 1; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Index exceeds matrix dimensions. Error in pGraph (line 6) ev = vars(1); Error in TestPoint1 (line 9) assert(isequal(pGraph(C),mat))

2   Fail
C = {'a=1;' 'a=1;' 'c=1;' 'c=1;'}; mat = [0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Index exceeds matrix dimensions. Error in pGraph (line 6) ev = vars(1); Error in TestPoint2 (line 9) assert(isequal(pGraph(C),mat))

3   Fail
C = {'a=1;' 'a=1;' 'c=a+1;' 'c=a+1;'}; mat = [0 0 0 0; 0 0 1 1; 0 0 0 0; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Index exceeds matrix dimensions. Error in pGraph (line 6) ev = vars(1); Error in TestPoint3 (line 9) assert(isequal(pGraph(C),mat))

4   Fail
C = {'a=1;' 'b=a+2;' 'c=b+1;' 'd=c+1;'}; mat = double(~tril(ones(4))) assert(isequal(pGraph(C),mat))

mat = 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0

Index exceeds matrix dimensions. Error in pGraph (line 6) ev = vars(1); Error in TestPoint4 (line 6) assert(isequal(pGraph(C),mat))