Skip to content

Commit cbbe55a

Browse files
committed
update adjacency_matrix
1 parent 24bddc8 commit cbbe55a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SQLiteGraph.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,16 @@ end
181181
Base.getindex(db::DB, ::Colon, ::Colon, ::Colon) = (Edge(row) for row in query(db,"*", "edges", "TRUE"))
182182

183183
#-----------------------------------------------------------------------------# adjacency_matrix
184-
function adjacency_matrix(db::DB)
184+
"""
185+
adjacency_matrix(db, type)
186+
187+
Create the adjacency matrix for a given edge `type`. If `A[i,j] == true`, there exists an
188+
edge from node `i` to node `j` with type `type`.
189+
"""
190+
function adjacency_matrix(db::DB, type)
185191
n = n_nodes(db)
186192
out = falses(n, n)
187-
for row in execute(db, "SELECT DISTINCT source, target FROM edges;")
193+
for row in execute(db, "SELECT DISTINCT source, target FROM edges WHERE type=?;", (type,))
188194
out[row.source, row.target] = true
189195
end
190196
out

0 commit comments

Comments
 (0)