Created
July 28, 2015 18:53
-
-
Save ZacCranko/16b9523f47450a2e514c 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
function DiGraph{T<:Real}(adjmx::AbstractMatrix{T}) | |
isequal(size(adjmx)...) || error("Adjacency / distance matrices must be square") | |
g = DiGraph(size(adjmx,1)) | |
for (s,d) in zip(findn(adjmx)...) | |
add_edge!(g,s,d) | |
end | |
return g | |
end |
sbromberger
commented
Jul 28, 2015
function DiGraph2{T<:Real}(adjmx::AbstractMatrix{T})
dima,dimb = size(adjmx)
isequal(dima,dimb) || error("Adjacency / distance matrices must be square")
g = DiGraph(dima)
s,d = findn(adjmx)
@inbounds for i = 1:dima
add_edge!(g,s[i],d[i])
end
return g
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment