Skip to content

Commit 51d839f

Browse files
authored
Merge pull request #23 from Mathics3/graph-properties-docs-again
Go over Graph properties docs
2 parents 6faf955 + 44f7608 commit 51d839f

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

pymathics/graph/properties.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AcyclicGraphQ(_NetworkXBuiltin):
5050
= True
5151
"""
5252

53-
summary_text = "test if is an acyclic graph"
53+
summary_text = "test if is a graph is acyclic"
5454

5555
def eval(self, graph, expression, evaluation, options):
5656
"AcyclicGraphQ[graph_, OptionsPattern[AcyclicGraphQ]]"
@@ -71,7 +71,7 @@ class ConnectedGraphQ(_NetworkXBuiltin):
7171
:Connected graph:
7272
https://en.wikipedia.org/wiki/Connectivity_(graph_theory)\
7373
#Connected_vertices_and_graphs
74-
</url> (<url>
74+
</url> test (<url>
7575
:NetworkX:
7676
https://networkx.org/documentation/networkx-2.8.8/reference/algorithms\
7777
/generated/networkx.algorithms.components.is_connected.html
@@ -110,7 +110,7 @@ class ConnectedGraphQ(_NetworkXBuiltin):
110110
= False
111111
"""
112112

113-
summary_text = "test if is a connected graph"
113+
summary_text = "test if a graph is a connected"
114114

115115
def eval(self, graph, expression, evaluation, options):
116116
"%(name)s[graph_, OptionsPattern[%(name)s]]"
@@ -126,7 +126,7 @@ class DirectedGraphQ(_NetworkXBuiltin):
126126
<url>
127127
:Directed graph:
128128
https://en.wikipedia.org/wiki/Directed_graph
129-
</url> (<url>
129+
</url> test (<url>
130130
:NetworkX:
131131
https://networkx.org/documentation/networkx-2.8.8/reference\
132132
/generated/networkx.classes.function.is_directed.html
@@ -153,10 +153,10 @@ class DirectedGraphQ(_NetworkXBuiltin):
153153
= False
154154
"""
155155

156-
summary_text = "test if is a directed graph"
156+
summary_text = "test if a graph is directed"
157157

158158
def eval(self, graph, expression, evaluation, options):
159-
"%(name)s[graph_, OptionsPattern[%(name)s]]"
159+
"DirectedGraphQ[graph_, OptionsPattern[DirectedGraphQ]]"
160160
graph = self._build_graph(graph, evaluation, options, expression, quiet=True)
161161
if graph:
162162
return from_python(graph.is_directed())
@@ -169,7 +169,7 @@ class LoopFreeGraphQ(_NetworkXBuiltin):
169169
<url>
170170
:Loop-Free graph:
171171
https://en.wikipedia.org/wiki/Loop_(graph_theory)
172-
</url> (<url>
172+
</url> test (<url>
173173
:NetworkX:
174174
https://networkx.org/documentation/networkx-2.8.8/reference/\
175175
generated/networkx.classes.function.nodes_with_selfloops.html
@@ -196,10 +196,10 @@ class LoopFreeGraphQ(_NetworkXBuiltin):
196196
= False
197197
"""
198198

199-
summary_text = "test if is a loop-free graph"
199+
summary_text = "test if a graph is loop free"
200200

201201
def eval(self, graph, expression, evaluation, options):
202-
"%(name)s[graph_, OptionsPattern[%(name)s]]"
202+
"LoopFreeGraphQ[graph_, OptionsPattern[LoopFreeGraphQ]]"
203203
graph = self._build_graph(graph, evaluation, options, expression, quiet=True)
204204
if not graph or graph.empty():
205205
return SymbolFalse
@@ -210,40 +210,41 @@ def eval(self, graph, expression, evaluation, options):
210210
class MixedGraphQ(_NetworkXBuiltin):
211211
"""
212212
<url>
213-
:WMA:
213+
:Mixed Graph:
214+
https://en.wikipedia.org/wiki/Mixed_graph</url> test <url>:WMA:
214215
https://reference.wolfram.com/language/ref/MixedGraphQ.html</url>
215216
216217
<dl>
217218
<dt>'MixedGraphQ'[$graph$]
218219
<dd>returns 'True' if $graph$ is a 'Graph' with both directed and undirected edges, \
219-
and 'False' otherwise.
220+
and 'False' otherwise.
220221
</dl>
221222
222-
>> g = Graph[{1 -> 2, 2 -> 3}]; MixedGraphQ[g]
223+
>> MixedGraphQ[Graph[{1 -> 2, 2 -> 3}]]
223224
= False
224225
225-
# Seems to not be implemented...
226-
# >> g = Graph[{1 -> 2, 2 <-> 3}]; MixedGraphQ[g]
227-
# = True
226+
>> MixedGraphQ[Graph[{1 -> 2, 2 <-> 3}]]
227+
= True
228228
229-
#> g = Graph[{}]; MixedGraphQ[g]
229+
>> MixedGraphQ[Graph[{}]]
230230
= False
231231
232-
#> MixedGraphQ["abc"]
232+
>> MixedGraphQ["abc"]
233233
= False
234234
235-
# #> g = Graph[{1 -> 2, 2 -> 3}]; MixedGraphQ[g]
236-
# = False
237-
# #> g = EdgeAdd[g, a <-> b]; MixedGraphQ[g]
238-
# = True
239-
# #> g = EdgeDelete[g, a <-> b]; MixedGraphQ[g]
240-
# = False
235+
## Add as pytests
236+
## > g = Graph[{1 -> 2, 2 -> 3}]; MixedGraphQ[g]
237+
## = False
238+
## > g = EdgeAdd[g, a <-> b]; MixedGraphQ[g]
239+
## = True
240+
## > g = EdgeDelete[g, a <-> b]; MixedGraphQ[g]
241+
## = False
241242
"""
242243

243-
summary_text = "test if is a graph with directed and undirected edges"
244+
summary_text = "test if a graph has directed and undirected edges"
244245

245246
def eval(self, graph, expression, evaluation, options):
246-
"%(name)s[graph_, OptionsPattern[%(name)s]]"
247+
"MixedGraphQ[graph_, OptionsPattern[MixedGraphQ]]"
247248
graph = self._build_graph(graph, evaluation, options, expression, quiet=True)
248249
if graph:
249250
return from_python(graph.is_mixed_graph())
@@ -253,9 +254,13 @@ def eval(self, graph, expression, evaluation, options):
253254
class MultigraphQ(_NetworkXBuiltin):
254255
"""
255256
<url>
257+
:Multigraph:
258+
https://en.wikipedia.org/wiki/Multigraph</url> test (<url>
256259
:NetworkX:
257-
https://networkx.org/documentation/networkx-2.8.8/reference/classes/multigraph.html
258-
</url>,
260+
https://networkx.org/documentation/networkx-2.8.8/reference/classes/multigraph.html</url>, <url>
261+
:WMA:
262+
https://reference.wolfram.com/language/ref/MulitGraphQ.html</url>)
263+
259264
260265
<dl>
261266
<dt>'MultigraphQ'[$graph$]
@@ -276,10 +281,10 @@ class MultigraphQ(_NetworkXBuiltin):
276281
= False
277282
"""
278283

279-
summary_text = "test if is a multi graph"
284+
summary_text = "test if a graph is a multi graph"
280285

281286
def eval(self, graph, expression, evaluation, options):
282-
"%(name)s[graph_, OptionsPattern[%(name)s]]"
287+
"MultigraphQ[graph_, OptionsPattern[MultigraphQ]]"
283288
graph = self._build_graph(graph, evaluation, options, expression, quiet=True)
284289
if graph:
285290
return from_python(graph.is_multigraph())
@@ -292,8 +297,7 @@ class PathGraphQ(_NetworkXBuiltin):
292297
<url>
293298
:Path graph:
294299
https://en.wikipedia.org/wiki/Path_graph
295-
</url> (
296-
<url>
300+
</url> (<url>
297301
:WMA:
298302
https://reference.wolfram.com/language/ref/PathGraphQ.html</url>)
299303
@@ -335,10 +339,10 @@ class PathGraphQ(_NetworkXBuiltin):
335339
= False
336340
"""
337341

338-
summary_text = "test if is a path-like graph"
342+
summary_text = "test if a graph is a path-like graph"
339343

340344
def eval(self, graph, expression, evaluation, options):
341-
"PathGraphQ[graph_, OptionsPattern[%(name)s]]"
345+
"PathGraphQ[graph_, OptionsPattern[PathGraphQ]]"
342346
if not isinstance(graph, Graph) or graph.empty():
343347
return SymbolFalse
344348

@@ -390,7 +394,7 @@ class PlanarGraphQ(_NetworkXBuiltin):
390394
"""
391395

392396
options = DEFAULT_GRAPH_OPTIONS
393-
summary_text = "test if is a planar graph"
397+
summary_text = "test if a graph is planar"
394398

395399
def eval(self, graph, expression, evaluation: Evaluation, options: dict):
396400
"Pymathics`PlanarGraphQ[graph_, OptionsPattern[PlanarGraphQ]]"
@@ -433,7 +437,7 @@ class SimpleGraphQ(_NetworkXBuiltin):
433437
= False
434438
"""
435439

436-
summary_text = "test if is a simple graph"
440+
summary_text = "test if a graph is simple"
437441

438442
def eval(self, graph, expression, evaluation, options):
439443
"%(name)s[graph_, OptionsPattern[%(name)s]]"

0 commit comments

Comments
 (0)