Skip to content

Commit 92a617d

Browse files
authored
slightly improved docs for graphs (#5171)
1 parent eb0323d commit 92a617d

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

docs/src/Combinatorics/graphs.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,32 @@ label!
5454
```
5555

5656
## Auxiliary functions
57+
58+
### Degrees
59+
```@docs
60+
degree(g::Graph, v::Int)
61+
indegree(g::Graph{Directed}, v::Int)
62+
outdegree(g::Graph{Directed}, v::Int)
63+
```
64+
65+
### Connectivity
66+
```@docs
67+
is_connected(g::Graph{Undirected})
68+
connected_components(g::Graph{Undirected})
69+
connectivity(g::Graph{Undirected})
70+
is_weakly_connected(g::Graph{Directed})
71+
is_strongly_connected(g::Graph{Directed})
72+
weakly_connected_components(g::Graph{Directed})
73+
diameter(g::Graph{T}) where {T <: Union{Directed, Undirected}}
74+
```
75+
76+
### Others
5777
```@docs
5878
adjacency_matrix(g::Graph)
5979
all_neighbors(g::Graph{T}, v::Int64) where {T <: Union{Directed, Undirected}}
6080
automorphism_group_generators(g::Graph{T}) where {T <: Union{Directed, Undirected}}
61-
connectivity(g::Graph{Undirected})
6281
complete_graph(n::Int64)
6382
complete_bipartite_graph(n::Int64, m::Int64)
64-
degree(g::Graph, v::Int)
65-
indegree(g::Graph{Directed}, v::Int)
66-
outdegree(g::Graph{Directed}, v::Int)
6783
vertices(g::Graph{T}) where {T <: Union{Directed, Undirected}}
6884
edges(g::Graph{T}) where {T <: Union{Directed, Undirected}}
6985
has_edge(g::Graph{T}, source::Int64, target::Int64) where {T <: Union{Directed, Undirected}}

src/Combinatorics/Graphs/functions.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,22 @@ true
984984
"""
985985
is_connected(g::Graph{Undirected}) = Polymake.call_function(:graph, :is_connected, pm_object(g))::Bool
986986

987+
@doc raw"""
988+
connected_components(g::Graph{Undirected})
989+
990+
Return the connected components of an undirected graph `g`.
991+
992+
# Examples
993+
```jldoctest
994+
julia> g = Graph{Undirected}(2);
995+
996+
julia> add_edge!(g, 1, 2);
997+
998+
julia> connected_components(g)
999+
1-element Vector{Vector{Int64}}:
1000+
[1, 2]
1001+
```
1002+
"""
9871003
function connected_components(g::Graph{Undirected})
9881004
im = Polymake.call_function(:graph, :connected_components, pm_object(g))::IncidenceMatrix
9891005
return [Vector(Polymake.row(im,i)) for i in 1:Polymake.nrows(im)]

0 commit comments

Comments
 (0)