@@ -44,15 +44,14 @@ julia> add_vertices!(g, 2)
4444"""
4545add_vertices! (g:: AbstractGraph , n:: Integer ) = sum ([add_vertex! (g) for i in 1 : n])
4646
47- # TODO the behaviour of indegree (and as well outdegree and degree) is very
48- # badly documented for the case indegree(g, vs) where vs is not a single vertex
49- # but rather a collection of vertices
50-
5147"""
5248 indegree(g[, v])
5349
54- Return a vector corresponding to the number of edges which end at each vertex in
55- graph `g`. If `v` is specified, only return degrees for vertices in `v`.
50+ Return a vector containing the indegrees of every vertex of the graph `g`, where
51+ the indegree of a vertex is defined as the number of edges which end at that
52+ vertex. If `v` is specified and is a single vertex, only return the indegree of
53+ `v`. If `v` is specified and is a vector of vertices, only return the indegrees
54+ of the vertices in `v`.
5655
5756# Examples
5857```jldoctest
@@ -69,6 +68,14 @@ julia> indegree(g)
6968 1
7069 0
7170 1
71+
72+ julia> indegree(g,[2,3])
73+ 2-element Vector{Int64}:
74+ 0
75+ 1
76+
77+ julia> indegree(g,2)
78+ 0
7279```
7380"""
7481indegree (g:: AbstractGraph , v:: Integer ) = length (inneighbors (g, v))
@@ -77,8 +84,11 @@ indegree(g::AbstractGraph, vs=vertices(g)) = [indegree(g, x) for x in vs]
7784"""
7885 outdegree(g[, v])
7986
80- Return a vector corresponding to the number of edges which start at each vertex in
81- graph `g`. If `v` is specified, only return degrees for vertices in `v`.
87+ Return a vector containing the outdegrees of every vertex of the graph `g`, where
88+ the outdegree of a vertex is defined as the number of edges which start at that
89+ vertex. If `v` is specified and is a single vertex, only return the outdegree of
90+ `v`. If `v` is specified and is a vector of vertices, only return the outdegrees
91+ of the vertices in `v`.
8292
8393# Examples
8494```jldoctest
@@ -95,6 +105,14 @@ julia> outdegree(g)
95105 0
96106 1
97107 1
108+
109+ julia> outdegree(g,[1,2])
110+ 2-element Vector{Int64}:
111+ 0
112+ 1
113+
114+ julia> outdegree(g,2)
115+ 1
98116```
99117"""
100118outdegree (g:: AbstractGraph , v:: Integer ) = length (outneighbors (g, v))
@@ -103,10 +121,12 @@ outdegree(g::AbstractGraph, vs=vertices(g)) = [outdegree(g, x) for x in vs]
103121"""
104122 degree(g[, v])
105123
106- Return a vector corresponding to the number of edges which start or end at each
107- vertex in graph `g`. If `v` is specified, only return degrees for vertices in `v`.
108- For directed graphs, this value equals the incoming plus outgoing edges.
109- For undirected graphs, it equals the connected edges.
124+ Return a vector containing the degrees of every vertex of the graph `g`, where
125+ the degree of a vertex is defined as the number of edges which start or end at
126+ that vertex. For directed graphs, the degree of a vertex is equal to the sum of
127+ its indegree and outdegree. If `v` is specified and is a single vertex, only
128+ return the degree of `v`. If `v` is specified and is a vector of vertices, only
129+ return the degrees of the vertices in `v`.
110130
111131# Examples
112132```jldoctest
@@ -123,6 +143,14 @@ julia> degree(g)
123143 1
124144 1
125145 2
146+
147+ julia> degree(g,[1,3])
148+ 2-element Vector{Int64}:
149+ 1
150+ 2
151+
152+ julia> degree(g,3)
153+ 2
126154```
127155"""
128156function degree end
0 commit comments