#P381. 【例66.1】 图论入门
【例66.1】 图论入门
Description
Suppose an array is used to represent the adjacency matrix of a directed graph:
(1) Write a function to determine the out-degree of a vertex.
(2) Write a function to determine the in-degree of a vertex.
(3) Write a function to determine the number of edges in the graph.
Input Format
The first line: total number of nodes , specified node , nodes are numbered starting from .
The next lines: the adjacency matrix of the directed graph.
Output Format
The first line outputs three numbers: node number , the out-degree of , and the in-degree of (separated by spaces).
The second line outputs: the total number of edges in the graph.
Sample
5 3
0 4 2 2 3
2 0 1 5 10
2 0 0 4 0
0 3 7 0 7
6 2 0 0 03 2 3
15
Related
In following homework: