Created
September 6, 2015 21:51
-
-
Save IainNZ/12a712c8650d0a95a20d 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
for col in 1:n | |
for idx in colptr[i]:colptr[i]-1 | |
row = rowval[idx] | |
nzv = nzvals[idx] | |
if row==col && nzv | |
return true | |
elseif row>col | |
break | |
end | |
end | |
end | |
return false |
sbromberger
commented
Sep 6, 2015
function has_self_loop(g::SimpleSparseGraph)
n = g.fm
colptr = g.fm.colptr
rowval = g.fm.rowval
nzval = g.fm.nzval
@inbounds for col in 1:n
for idx in colptr[col]:colptr[col+1]-1
row = rowval[idx]
nzv = nzval[idx]
if row == col && nzv
return true
elseif row > col
break
end
end
end
return false
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment