java - how to calculate outdegree of DAG which is represented using adjancency matrix -
i need method calculate outdegree of each vertex of dag check whether leaf or not.i m using java boolean adjancency matrix representation
sum along row. in adjacency matrix, there 1 @ position (i, j) if there edge vertex i vertex j. therefore, outgoing edges of vertex i in row i. sum of row i therefore gives outdegree of vertex i.
for transposed adjacency matrix, sum along columns.
like david says, if you're interested in whether outdegree 0 or not can save work stopping summation if find 1.
Comments
Post a Comment