Skip to content

Commit 970cafc

Browse files
authored
add doc string to each exported binding (#4)
Also add some properties.
1 parent 4936386 commit 970cafc

File tree

1 file changed

+99
-72
lines changed

1 file changed

+99
-72
lines changed

src/GraphProperties.jl

Lines changed: 99 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,20 @@ export
44
GraphProperty,
55
PropertyComparison
66

7+
"""
8+
GraphProperty::Type
9+
10+
Abstract supertype for graph properties.
11+
12+
The only type parameter is the type of each value of the property.
13+
"""
714
abstract type GraphProperty{T} end
815

16+
"""
17+
PropertyComparison(comparison, property, value)
18+
19+
Turn a `GraphProperty{<:Real}` into a `GraphProperty{Bool}` by attaching a comparison against a value.
20+
"""
921
struct PropertyComparison{
1022
Comparison <: Union{typeof(==), typeof(≤)},
1123
Property <: GraphProperty{<:Real},
@@ -17,90 +29,105 @@ struct PropertyComparison{
1729
end
1830

1931
let
20-
properties_abstractvector = Symbol[
21-
:DegreeSequence,
32+
properties_abstractvector = Tuple{Symbol, String}[
33+
(:DegreeSequence, "The *degree sequence* of an undirected graph."),
2234
]
23-
properties_real = Symbol[
24-
:FractionalChromaticNumber,
25-
:FractionalMatchingNumber,
35+
properties_real = Tuple{Symbol, String}[
36+
(:FractionalChromaticNumber, "The *fractional chromatic number* of an undirected graph."),
37+
(:FractionalMatchingNumber, "The *fractional matching number* of an undirected graph."),
38+
(:Strength, "The *strength* of an undirected graph."),
2639
]
27-
properties_integer = Symbol[
28-
:NumberOfVertices,
29-
:NumberOfEdges,
30-
:NumberOfArcs,
31-
:NumberOfConnectedComponents,
32-
:MinimumDegree,
33-
:MaximumDegree,
34-
:Girth,
35-
:VertexConnectivity,
36-
:EdgeConnectivity,
37-
:CliqueNumber,
38-
:ChromaticNumber,
39-
:ChromaticIndex,
40-
:MatchingNumber,
41-
:DominationNumber,
42-
:IndependenceNumber,
43-
:Choosability,
44-
:FeedbackVertexSetNumber,
45-
:VertexCoverNumber,
46-
:EdgeCoverNumber,
47-
:IntersectionNumber,
48-
:BipartiteDimension,
49-
:HadwigerNumber,
50-
:TwinWidth,
51-
:CliqueWidth,
52-
:Treewidth,
53-
:Pathwidth,
54-
:Boxicity,
55-
:Degeneracy,
56-
:Arboricity,
57-
:Splittance,
40+
properties_integer = Tuple{Symbol, String}[
41+
(:NumberOfVertices, "The *number of vertices* of a graph."),
42+
(:NumberOfEdges, "The *number of edges* of an undirected graph."),
43+
(:NumberOfArcs, "The *number of arcs* of a directed graph."),
44+
(:NumberOfConnectedComponents, "The *number of connected components* of an undirected graph."),
45+
(:MinimumDegree, "The *minimum degree* among the degrees of the vertices of an undirected graph."),
46+
(:MaximumDegree, "The *maximum degree* among the degrees of the vertices of an undirected graph."),
47+
(:Girth, "The *girth* of a undirected graph: the length of its shortest cycle."),
48+
(:VertexConnectivity, "The *vertex-connectivity* of an undirected graph. Also known as the *connectivity*."),
49+
(:EdgeConnectivity, "The *edge-connectivity* of an undirected graph."),
50+
(:CliqueNumber, "The *clique number* of an undirected graph."),
51+
(:ChromaticNumber, "The *chromatic number* of an undirected graph."),
52+
(:ChromaticIndex, "The *chromatic index* of an undirected graph. Also known as the *edge chromatic number*."),
53+
(:MatchingNumber, "The *matching number* of an undirected graph."),
54+
(:DominationNumber, "The *domination number* of an undirected graph."),
55+
(:StrongDominationNumber, "The *strong domination number* of an undirected graph."),
56+
(:IndependenceNumber, "The *independence number* of an undirected graph."),
57+
(:Choosability, "The *choosability* of an undirected graph. Also known as the *list colorability* or as the *list chromatic number*."),
58+
(:FeedbackVertexSetNumber, "The *feedback vertex set number* of a graph."),
59+
(:VertexCoverNumber, "The *vertex cover number* of an undirected graph."),
60+
(:EdgeCoverNumber, "The *edge cover number* of an undirected graph."),
61+
(:IntersectionNumber, "The *intersection number* of an undirected graph. Also known as the *R-content* or as the *edge clique cover number* or as the *clique cover number*."),
62+
(:BipartiteDimension, "The *bipartite dimension* of an undirected graph. Also known as the *biclique cover number*."),
63+
(:HadwigerNumber, "The *Hadwiger number* of an undirected graph. Also known as the *contraction clique number* or as the *homomorphism degree*."),
64+
(:TwinWidth, "The *twin-width* of an undirected graph."),
65+
(:CliqueWidth, "The *clique-width* of an undirected graph."),
66+
(:Treewidth, "The *treewidth* of an undirected graph."),
67+
(:Pathwidth, "The *pathwidth* of an undirected graph. Also known as the *interval thickness* or as the *vertex separation number* or as the *node searching number*."),
68+
(:Boxicity, "The *boxicity* of an undirected graph."),
69+
(:Sphericity, "The *sphericity* of an undirected graph."),
70+
(:Degeneracy, "The *degeneracy* of an undirected graph. Also known as the *width* or as the *linkage*."),
71+
(:Arboricity, "The *arboricity* of an undirected graph."),
72+
(:Splittance, "The *splittance* of an undirected graph."),
5873
]
59-
properties_bool = Symbol[
60-
:IsUndirectedGraph,
61-
:IsDirectedGraph,
62-
:DigraphIsDAG,
63-
:DigraphIsOrientation,
64-
:GraphIsConnected,
65-
:DigraphIsWeaklyConnected,
66-
:DigraphIsStronglyConnected,
67-
:GraphIsBipartite,
68-
:GraphIsPath,
69-
:GraphIsCycle,
70-
:GraphIsPlanar,
71-
:DigraphIsPlanar,
72-
:GraphIsTriangleFree,
73-
:GraphIsComplete,
74-
:GraphIsRegular,
75-
:GraphIsPerfect,
76-
:GraphIsTriviallyPerfect,
77-
:GraphIsForest,
78-
:GraphIsTree,
79-
:GraphIsIndifferenceGraph,
80-
:GraphIsIntervalGraph,
81-
:GraphIsPtolemaic,
82-
:GraphIsChordal,
83-
:GraphIsMeynielGraph,
84-
:GraphIsCircleGraph,
85-
:GraphIsPermutationGraph,
86-
:GraphIsCograph,
87-
:GraphIsComparabilityGraph,
88-
:GraphIsDistanceHereditary,
89-
:GraphIsSplitGraph,
74+
properties_bool = Tuple{Symbol, String}[
75+
(:IsUndirectedGraph, "Is something an undirected graph?"),
76+
(:IsDirectedGraph, "Is something a directed graph?"),
77+
(:DigraphIsDAG, "Is a directed graph acyclic (a DAG)?"),
78+
(:DigraphIsOrientation, "Is a directed graph an orientation?"),
79+
(:GraphIsConnected, "Is an undirected graph connected?"),
80+
(:DigraphIsWeaklyConnected, "Is a directed graph weakly connected?"),
81+
(:DigraphIsStronglyConnected, "Is a directed graph strongly connected?"),
82+
(:GraphIsBipartite, "Is an undirected graph bipartite?"),
83+
(:GraphIsPath, "Is an undirected graph a path?"),
84+
(:GraphIsCycle, "Is an undirected graph a cycle?"),
85+
(:GraphIsPlanar, "Is an undirected graph planar?"),
86+
(:DigraphIsPlanar, "Is a directed graph planar?"),
87+
(:GraphIsTriangleFree, "Is an undirected graph triangle-free?"),
88+
(:GraphIsComplete, "Is an undirected graph complete?"),
89+
(:GraphIsRegular, "Is an undirected graph regular?"),
90+
(:GraphIsPerfect, "Is an undirected graph perfect?"),
91+
(:GraphIsTriviallyPerfect, "Is an undirected graph trivially perfect?"),
92+
(:GraphIsForest, "Is an undirected graph a forest?"),
93+
(:GraphIsTree, "Is an undirected graph a tree?"),
94+
(:GraphIsIndifferenceGraph, "Is an undirected graph an indifference graph?"),
95+
(:GraphIsIntervalGraph, "Is an undirected graph an interval graph?"),
96+
(:GraphIsPtolemaic, "Is an undirected graph Ptolemaic?"),
97+
(:GraphIsChordal, "Is an undirected graph chordal?"),
98+
(:GraphIsMeynielGraph, "Is an undirected graph a Meyniel graph?"),
99+
(:GraphIsCircleGraph, "Is an undirected graph a circle graph?"),
100+
(:GraphIsPermutationGraph, "Is an undirected graph a permutation graph?"),
101+
(:GraphIsCograph, "Is an undirected graph a cograph?"),
102+
(:GraphIsComparabilityGraph, "Is an undirected graph a comparability graph?"),
103+
(:GraphIsDistanceHereditary, "Is an undirected graph distance-hereditary?"),
104+
(:GraphIsSplitGraph, "Is an undirected graph a split graph?"),
90105
]
91106
for (typ, properties) (
92107
(AbstractVector, properties_abstractvector),
93108
(Real, properties_real),
94109
(Integer, properties_integer),
95110
(Bool, properties_bool),
96111
)
97-
for p properties
98-
@eval export $p
99-
@eval struct $p <: GraphProperty{$typ} end
112+
for (name, desc) properties
113+
@eval export $name
114+
@eval begin
115+
"""
116+
$($name)()
117+
118+
$($desc)
119+
120+
```jldoctest
121+
julia> using GraphProperties
122+
123+
julia> $($name)() isa GraphProperty{$($typ)}
124+
true
125+
```
126+
"""
127+
struct $name <: GraphProperty{$typ} end
128+
end
100129
end
101130
end
102131
end
103132

104-
# TODO: doc strings
105-
106133
end

0 commit comments

Comments
 (0)