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

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -