Last active
July 1, 2016 13:29
-
-
Save mihaeu/5881338d2943f469d6e404a7fb378552 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BROKEN | |
// BROKEN | |
// BROKEN | |
// BROKEN | |
function returnString=isPeriodic(P) | |
// initialize entered and left | |
for i=1:size(P, 1) | |
for j=1:size(P, 2) | |
entered(i, j) = %F | |
left(i, j) = %F | |
end | |
end | |
// search all edges for connections | |
for i=1:size(P, 1) | |
for j=1:size(P, 2) | |
if entered(i, j) == %F then | |
[entered, left, foundCircle] = findCircle(P, entered, left, i) | |
if foundCircle == %T then | |
returnString = "periodisch" | |
return | |
end | |
end | |
end | |
end | |
disp(entered, left) | |
returnString="nicht periodisch" | |
endfunction | |
function [entered, left, foundCircle]=findCircle(P, entered, left, i) | |
foundCircle = %F | |
entered(i, j) = %T | |
for k=1:size(P, 2) | |
if i <> k & P(i, k) == 1 then | |
//disp(entered, "entered") | |
//disp(left, "left") | |
if entered(i, k) == %F then | |
[entered, left, foundCircle] = findCircle(P, entered, left, k) | |
if foundCircle == %T then | |
return | |
end | |
else | |
if left(i, k) == %F then | |
// we were already here but couldn't leave, so we know | |
// that the matrix is not periodical | |
foundCircle = %T | |
return | |
end | |
end | |
end | |
end | |
left(i, j) = %T | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment