data-structures · intermediate · ~15 min
Read a column of the adjacency matrix.
int in_degree(const int *adj,int n,int v);
Return the in-degree of v (edges pointing into v) in a directed graph.
adj n×n directed 0/1.
In-degree of v.
—
#include <stddef.h>
/* In-degree of node v in the directed adjacency matrix (edges pointing to v). */
int in_degree(const int *adj,int n,int v){ (void)adj;(void)n;(void)v; return 0; }
Summing row v (that is out-degree) instead of column v.
Source vertex → 0.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.