Skip to content

Commit 361dffd

Browse files
authored
less redundancy when building doc strings (#23)
Fixes #21
1 parent c87f8eb commit 361dffd

File tree

1 file changed

+116
-100
lines changed

1 file changed

+116
-100
lines changed

src/GraphProperties.jl

Lines changed: 116 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -41,123 +41,139 @@ struct PropertyComparison{
4141
end
4242

4343
let
44-
properties_abstractvector_integer = Tuple{Symbol, String}[
45-
(:DegreeSequence, "The *degree sequence* of an undirected graph."),
44+
ag = "a graph"
45+
ug = "an undirected graph"
46+
dg = "a directed graph"
47+
cg = "a connected undirected graph"
48+
properties_abstractvector_integer = Tuple{Symbol, String, Vector{String}, String}[
49+
(:DegreeSequence, "*degree sequence*", [], ug),
4650
]
47-
properties_real = Tuple{Symbol, String}[
48-
(:FractionalChromaticNumber, "The *fractional chromatic number* of an undirected graph."),
49-
(:FractionalMatchingNumber, "The *fractional matching number* of an undirected graph."),
50-
(:Strength, "The *strength* of an undirected graph."),
51-
(:AssortativityCoefficient, "The *assortativity coefficient* of an undirected graph."),
52-
(:GlobalClusteringCoefficient, "The *global clustering coefficient* of an undirected graph."),
53-
(:CheegerConstant, "The *Cheeger constant* of an undirected graph. Also known as the *Cheeger number* or as the *isoperimetric number*."),
54-
(:Circumference, "The *circumference* of an undirected graph."),
55-
(:Girth, "The *girth* of an undirected graph."),
51+
properties_real = Tuple{Symbol, String, Vector{String}, String}[
52+
(:FractionalChromaticNumber, "*fractional chromatic number*", [], ug),
53+
(:FractionalMatchingNumber, "*fractional matching number*", [], ug),
54+
(:Strength, "*strength*", [], ug),
55+
(:AssortativityCoefficient, "*assortativity coefficient*", [], ug),
56+
(:GlobalClusteringCoefficient, "*global clustering coefficient*", [], ug),
57+
(:CheegerConstant, "*Cheeger constant*", ["*Cheeger number*", "*isoperimetric number*"], ug),
58+
(:Circumference, "*circumference*", [], ug),
59+
(:Girth, "*girth*", [], ug),
5660
]
57-
properties_integer = Tuple{Symbol, String}[
58-
(:NumberOfVertices, "The *number of vertices* of a graph."),
59-
(:NumberOfEdges, "The *number of edges* of an undirected graph."),
60-
(:NumberOfArcs, "The *number of arcs* of a directed graph."),
61-
(:NumberOfConnectedComponents, "The *number of connected components* of an undirected graph."),
62-
(:NumberOfWeaklyConnectedComponents, "The *number of weakly connected components* of a directed graph."),
63-
(:NumberOfStronglyConnectedComponents, "The *number of strongly connected components* of a directed graph."),
64-
(:MinimumDegree, "The *minimum degree* among the degrees of the vertices of an undirected graph."),
65-
(:MaximumDegree, "The *maximum degree* among the degrees of the vertices of an undirected graph."),
66-
(:MinimumIndegree, "The *minimum indegree* among the indegrees of the vertices of a directed graph."),
67-
(:MaximumIndegree, "The *maximum indegree* among the indegrees of the vertices of a directed graph."),
68-
(:MinimumOutdegree, "The *minimum outdegree* among the outdegrees of the vertices of a directed graph."),
69-
(:MaximumOutdegree, "The *maximum outdegree* among the outdegrees of the vertices of a directed graph."),
70-
(:Radius, "The *radius* of a connected undirected graph."),
71-
(:Diameter, "The *diameter* of a connected undirected graph."),
72-
(:Triameter, "The *triameter* of a connected undirected graph."),
73-
(:VertexConnectivity, "The *vertex-connectivity* of an undirected graph. Also known as the *connectivity*."),
74-
(:EdgeConnectivity, "The *edge-connectivity* of an undirected graph."),
75-
(:CliqueNumber, "The *clique number* of an undirected graph."),
76-
(:ChromaticNumber, "The *chromatic number* of an undirected graph."),
77-
(:ChromaticIndex, "The *chromatic index* of an undirected graph. Also known as the *edge chromatic number*."),
78-
(:MatchingNumber, "The *matching number* of an undirected graph."),
79-
(:DominationNumber, "The *domination number* of an undirected graph."),
80-
(:StrongDominationNumber, "The *strong domination number* of an undirected graph."),
81-
(:IndependenceNumber, "The *independence number* of an undirected graph."),
82-
(:Choosability, "The *choosability* of an undirected graph. Also known as the *list colorability* or as the *list chromatic number*."),
83-
(:FeedbackVertexSetNumber, "The *feedback vertex set number* of a graph."),
84-
(:VertexCoverNumber, "The *vertex cover number* of an undirected graph."),
85-
(:EdgeCoverNumber, "The *edge cover number* of an undirected graph."),
86-
(: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*."),
87-
(:BipartiteDimension, "The *bipartite dimension* of an undirected graph. Also known as the *biclique cover number*."),
88-
(:HadwigerNumber, "The *Hadwiger number* of an undirected graph. Also known as the *contraction clique number* or as the *homomorphism degree*."),
89-
(:TwinWidth, "The *twin-width* of an undirected graph."),
90-
(:CliqueWidth, "The *clique-width* of an undirected graph."),
91-
(:TreeDepth, "The *tree-depth* of a connected undirected graph."),
92-
(:CycleRank, "The *cycle rank* of a directed graph."),
93-
(:Treewidth, "The *treewidth* of an undirected graph."),
94-
(: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*."),
95-
(:Boxicity, "The *boxicity* of an undirected graph."),
96-
(:Sphericity, "The *sphericity* of an undirected graph."),
97-
(:Degeneracy, "The *degeneracy* of an undirected graph. Also known as the *width* or as the *linkage*."),
98-
(:Arboricity, "The *arboricity* of an undirected graph."),
99-
(:Splittance, "The *splittance* of an undirected graph."),
61+
properties_integer = Tuple{Symbol, String, Vector{String}, String}[
62+
(:NumberOfVertices, "*number of vertices*", ["*order*"], ag),
63+
(:NumberOfEdges, "*number of edges*", ["*size*"], ug),
64+
(:NumberOfArcs, "*number of arcs*", [], dg),
65+
(:NumberOfConnectedComponents, "*number of connected components*", [], ug),
66+
(:NumberOfWeaklyConnectedComponents, "*number of weakly connected components*", [], dg),
67+
(:NumberOfStronglyConnectedComponents, "*number of strongly connected components*", [], dg),
68+
(:MinimumDegree, "*minimum degree*", [], ug),
69+
(:MaximumDegree, "*maximum degree*", [], ug),
70+
(:MinimumIndegree, "*minimum indegree*", [], dg),
71+
(:MaximumIndegree, "*maximum indegree*", [], dg),
72+
(:MinimumOutdegree, "*minimum outdegree*", [], dg),
73+
(:MaximumOutdegree, "*maximum outdegree*", [], dg),
74+
(:Radius, "*radius*", [], cg),
75+
(:Diameter, "*diameter*", [], cg),
76+
(:Triameter, "*triameter*", [], cg),
77+
(:VertexConnectivity, "*vertex-connectivity*", ["*connectivity*"], ug),
78+
(:EdgeConnectivity, "*edge-connectivity*", [], ug),
79+
(:CliqueNumber, "*clique number*", [], ug),
80+
(:ChromaticNumber, "*chromatic number*", [], ug),
81+
(:ChromaticIndex, "*chromatic index*", ["*edge chromatic number*"], ug),
82+
(:MatchingNumber, "*matching number*", [], ug),
83+
(:DominationNumber, "*domination number*", [], ug),
84+
(:StrongDominationNumber, "*strong domination number*", [], ug),
85+
(:IndependenceNumber, "*independence number*", [], ug),
86+
(:Choosability, "*choosability*", ["*list colorability*", "*list chromatic number*"], ug),
87+
(:FeedbackVertexSetNumber, "*feedback vertex set number*", [], ag),
88+
(:VertexCoverNumber, "*vertex cover number*", [], ug),
89+
(:EdgeCoverNumber, "*edge cover number*", [], ug),
90+
(:IntersectionNumber, "*intersection number*", ["*R-content*", "*edge clique cover number*", "*clique cover number*"], ug),
91+
(:BipartiteDimension, "*bipartite dimension*", ["*biclique cover number*"], ug),
92+
(:HadwigerNumber, "*Hadwiger number*", ["*contraction clique number*", "*homomorphism degree*"], ug),
93+
(:TwinWidth, "*twin-width*", [], ug),
94+
(:CliqueWidth, "*clique-width*", [], ug),
95+
(:TreeDepth, "*tree-depth*", [], ug),
96+
(:CycleRank, "*cycle rank*", [], dg),
97+
(:Treewidth, "*treewidth*", [], ug),
98+
(:Pathwidth, "*pathwidth*", ["*interval thickness*", "*vertex separation number*", "*node searching number*"], ug),
99+
(:Boxicity, "*boxicity*", [], ug),
100+
(:Sphericity, "*sphericity*", [], ug),
101+
(:Degeneracy, "*degeneracy*", ["*width*", "*linkage*"], ug),
102+
(:Arboricity, "*arboricity*", [], ug),
103+
(:Splittance, "*splittance*", [], ug),
100104
]
101-
properties_bool = Tuple{Symbol, String}[
102-
(:IsUndirectedGraph, "Is something an *undirected graph*?"),
103-
(:IsDirectedGraph, "Is something a *directed graph*?"),
104-
(:DigraphIsDAG, "Is a directed graph *acyclic* (a *directed acyclic graph*, also known as a *DAG*)?"),
105-
(:DigraphIsOrientation, "Is a directed graph an *orientation*?"),
106-
(:GraphIsConnected, "Is an undirected graph *connected*?"),
107-
(:DigraphIsWeaklyConnected, "Is a directed graph *weakly connected*?"),
108-
(:DigraphIsStronglyConnected, "Is a directed graph *strongly connected*?"),
109-
(:GraphIsBipartite, "Is an undirected graph *bipartite*?"),
110-
(:GraphIsCompleteBipartite, "Is an undirected graph *complete bipartite*? Also known as *biclique*."),
111-
(:GraphIsPath, "Is an undirected graph a *path*?"),
112-
(:GraphIsCycle, "Is an undirected graph a *cycle*?"),
113-
(:GraphIsPlanar, "Is an undirected graph *planar*?"),
114-
(:DigraphIsPlanar, "Is a directed graph *planar*?"),
115-
(:GraphIsOuterplanar, "Is an undirected graph *outerplanar*?"),
116-
(:GraphIsMaximalOuterplanar, "Is an undirected graph *maximal outerplanar*?"),
117-
(:GraphIsTriangleFree, "Is an undirected graph *triangle-free*?"),
118-
(:GraphIsComplete, "Is an undirected graph *complete*?"),
119-
(:GraphIsRegular, "Is an undirected graph *regular*?"),
120-
(:GraphIsDistanceRegular, "Is an undirected graph *distance-regular*?"),
121-
(:GraphIsDistanceTransitive, "Is an undirected graph *distance-transitive*?"),
122-
(:GraphIsStronglyRegular, "Is an undirected graph *strongly regular*?"),
123-
(:GraphIsPerfect, "Is an undirected graph *perfect*?"),
124-
(:GraphIsTriviallyPerfect, "Is an undirected graph *trivially perfect*?"),
125-
(:GraphIsModular, "Is an undirected graph *modular*?"),
126-
(:GraphIsMedianGraph, "Is an undirected graph a *median graph*?"),
127-
(:GraphIsSquaregraph, "Is an undirected graph a *squaregraph*?"),
128-
(:GraphIsForest, "Is an undirected graph a *forest*?"),
129-
(:GraphIsTree, "Is an undirected graph a *tree*?"),
130-
(:GraphIsStar, "Is an undirected graph a *star*?"),
131-
(:GraphIsIndifferenceGraph, "Is an undirected graph an *indifference graph*?"),
132-
(:GraphIsIntervalGraph, "Is an undirected graph an *interval graph*?"),
133-
(:GraphIsPtolemaic, "Is an undirected graph *Ptolemaic*?"),
134-
(:GraphIsChordal, "Is an undirected graph *chordal*?"),
135-
(:GraphIsStronglyChordal, "Is an undirected graph *strongly chordal*?"),
136-
(:GraphIsDuallyChordal, "Is an undirected graph *dually chordal*? Note: a dually chordal graph is not always chordal."),
137-
(:GraphIsChordalBipartite, "Is an undirected graph *chordal bipartite*? Note: a chordal bipartite graph is not always chordal."),
138-
(:GraphIsMeynielGraph, "Is an undirected graph a *Meyniel graph*?"),
139-
(:GraphIsCircleGraph, "Is an undirected graph a *circle graph*?"),
140-
(:GraphIsPermutationGraph, "Is an undirected graph a *permutation graph*?"),
141-
(:GraphIsCograph, "Is an undirected graph a *cograph*?"),
142-
(:GraphIsComparabilityGraph, "Is an undirected graph a *comparability graph*?"),
143-
(:GraphIsDistanceHereditary, "Is an undirected graph *distance-hereditary*?"),
144-
(:GraphIsSplitGraph, "Is an undirected graph a *split graph*?"),
145-
(:GraphIsCartesianProduct, "Is an undirected graph a *Cartesian product* of two graphs? Also known as the *box product*."),
105+
properties_bool = Tuple{Symbol, String, Vector{String}, String}[
106+
(:IsUndirectedGraph, "an *undirected graph*", [], ag),
107+
(:IsDirectedGraph, "a *directed graph*", ["a *digraph*"], ag),
108+
(:DigraphIsDAG, "a *directed acyclic graph*", ["a *DAG*"], dg),
109+
(:DigraphIsOrientation, "an *orientation*", [], dg),
110+
(:GraphIsConnected, "*connected*", [], ug),
111+
(:DigraphIsWeaklyConnected, "*weakly connected*", [], dg),
112+
(:DigraphIsStronglyConnected, "*strongly connected*", [], dg),
113+
(:GraphIsBipartite, "*bipartite*", [], ug),
114+
(:GraphIsCompleteBipartite, "*complete bipartite*", ["a *biclique*"], ug),
115+
(:GraphIsPath, "a *path*", [], ug),
116+
(:GraphIsCycle, "a *cycle*", [], ug),
117+
(:GraphIsPlanar, "*planar*", [], ug),
118+
(:DigraphIsPlanar, "*planar*", [], dg),
119+
(:GraphIsOuterplanar, "*outerplanar*", [], ug),
120+
(:GraphIsMaximalOuterplanar, "*maximal outerplanar*", [], ug),
121+
(:GraphIsTriangleFree, "*triangle-free*", [], ug),
122+
(:GraphIsComplete, "*complete*", [], ug),
123+
(:GraphIsRegular, "*regular*", [], ug),
124+
(:GraphIsDistanceRegular, "*distance-regular*", [], ug),
125+
(:GraphIsDistanceTransitive, "*distance-transitive*", [], ug),
126+
(:GraphIsStronglyRegular, "*strongly regular*", [], ug),
127+
(:GraphIsPerfect, "*perfect*", [], ug),
128+
(:GraphIsTriviallyPerfect, "*trivially perfect*", [], ug),
129+
(:GraphIsModular, "*modular*", [], ug),
130+
(:GraphIsMedianGraph, "a *median graph*", [], ug),
131+
(:GraphIsSquaregraph, "a *squaregraph*", [], ug),
132+
(:GraphIsForest, "a *forest*", [], ug),
133+
(:GraphIsTree, "a *tree*", [], ug),
134+
(:GraphIsStar, "a *star*", [], ug),
135+
(:GraphIsIndifferenceGraph, "an *indifference graph*", [], ug),
136+
(:GraphIsIntervalGraph, "an *interval graph*", [], ug),
137+
(:GraphIsPtolemaic, "*Ptolemaic*", [], ug),
138+
(:GraphIsChordal, "*chordal*", [], ug),
139+
(:GraphIsStronglyChordal, "*strongly chordal*", [], ug),
140+
(:GraphIsDuallyChordal, "*dually chordal*", [], ug),
141+
(:GraphIsChordalBipartite, "*chordal bipartite*", [], ug),
142+
(:GraphIsMeynielGraph, "a *Meyniel graph*", [], ug),
143+
(:GraphIsCircleGraph, "a *circle graph*", [], ug),
144+
(:GraphIsPermutationGraph, "a *permutation graph*", [], ug),
145+
(:GraphIsCograph, "a *cograph*", [], ug),
146+
(:GraphIsComparabilityGraph, "a *comparability graph*", [], ug),
147+
(:GraphIsDistanceHereditary, "*distance-hereditary*", [], ug),
148+
(:GraphIsSplitGraph, "a *split graph*", [], ug),
149+
(:GraphIsCartesianProduct, "a *Cartesian product* of two graphs", ["a box product"], ug),
146150
]
147151
for (typ, properties) (
148152
(AbstractVector{<:Integer}, properties_abstractvector_integer),
149153
(Real, properties_real),
150154
(Integer, properties_integer),
151155
(Bool, properties_bool),
152156
)
153-
for (name, desc) properties
157+
for (name, natural_name, aliases, assumed) properties
158+
lead = if typ == Bool
159+
"Is $assumed $natural_name?"
160+
else
161+
"The $natural_name of $assumed."
162+
end
163+
desc = if isempty(aliases)
164+
lead
165+
else
166+
string(lead, " Also known as:\n\n", mapreduce((a -> string("* ", a)), ((l, r) -> string(l, "\n\n", r)), aliases))
167+
end
154168
@eval export $name
155169
@eval begin
156170
"""
157171
$($name)()
158172
159173
$($desc)
160174
175+
Example:
176+
161177
```jldoctest
162178
julia> using GraphProperties
163179

0 commit comments

Comments
 (0)