Skip to content

Commit 9938b38

Browse files
authored
More docs (#19)
* more docs and restore the tests on documentation
1 parent 57a1161 commit 9938b38

File tree

6 files changed

+263
-12
lines changed

6 files changed

+263
-12
lines changed

pymathics/graph/base.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,8 @@ class AdjacencyList(_NetworkXBuiltin):
10541054
= {2, 11, 100, x}
10551055
"""
10561056

1057+
summary_text = "list the adjacent vertices"
1058+
10571059
def _retrieve(self, graph, what, neighbors, expression, evaluation):
10581060
from mathics.builtin import pattern_objects
10591061

@@ -1519,6 +1521,10 @@ def eval_s_t(self, graph, s, t, expression, evaluation, options):
15191521

15201522
class FindVertexCut(_NetworkXBuiltin):
15211523
"""
1524+
<url>
1525+
:WMA:
1526+
https://reference.wolfram.com/language/ref/FindVertexCut.html</url>
1527+
15221528
<dl>
15231529
<dt>'FindVertexCut[$g$]'
15241530
<dd>finds a set of vertices of minimum cardinality that, if removed, renders $g$ disconnected.
@@ -1574,6 +1580,9 @@ def eval_st(self, graph, s, t, expression, evaluation, options):
15741580

15751581
class GraphAtom(AtomBuiltin):
15761582
"""
1583+
<url>:Graph:https://en.wikipedia.org/wiki/graph</url> (
1584+
<url>:WMA:
1585+
https://reference.wolfram.com/language/ref/Graph.html</url>)
15771586
<dl>
15781587
<dt>'Graph[{$e1, $e2, ...}]'
15791588
<dd>returns a graph with edges $e_j$.
@@ -1610,6 +1619,7 @@ class GraphAtom(AtomBuiltin):
16101619
# requires = ("networkx",)
16111620
name = "Graph"
16121621
options = DEFAULT_GRAPH_OPTIONS
1622+
summary_text = "build a graph"
16131623

16141624
def eval(self, graph, evaluation, options):
16151625
"Pymathics`Graph[graph_List, OptionsPattern[%(name)s]]"
@@ -1867,7 +1877,19 @@ def eval_alpha_beta(self, graph, alpha, expression, evaluation, options):
18671877

18681878

18691879
class Property(Builtin):
1870-
pass
1880+
"""
1881+
<url>
1882+
:WMA:
1883+
https://reference.wolfram.com/language/ref/Property.html</url>
1884+
1885+
<dl>
1886+
<dt>'Property'[$item$, {$name$, $val$}]
1887+
<dd>associate a property called $name$ with value $val$ to $item$.
1888+
</dl>
1889+
1890+
"""
1891+
1892+
summary_text = "assign a property"
18711893

18721894

18731895
class PropertyValue(Builtin):
@@ -2041,6 +2063,9 @@ def eval(self, graph, what, expression, evaluation, options):
20412063

20422064
class VertexIndex(_NetworkXBuiltin):
20432065
"""
2066+
<url>
2067+
:WMA:
2068+
https://reference.wolfram.com/language/ref/VertexIndex.html</url>
20442069
<dl>
20452070
<dt>'VertexIndex'['g', 'v']
20462071
<dd> gives the integer index of the vertex 'v' in the\
@@ -2066,6 +2091,9 @@ def eval(self, graph, v, expression, evaluation, options):
20662091

20672092
class VertexList(_PatternList):
20682093
"""
2094+
<url>
2095+
:WMA:
2096+
https://reference.wolfram.com/language/ref/VertexList.html</url>
20692097
<dl>
20702098
<dt>'VertexList[$edgelist$]'
20712099
<dd>list the nodes from a list of directed edges.

pymathics/graph/operations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
class FindSpanningTree(_NetworkXBuiltin):
2020
"""
21+
<url>:Spanning Tree:https://en.wikipedia.org/wiki/Spanning_tree</url>
22+
(<url>:WMA:
23+
https://reference.wolfram.com/language/ref/FindSpanningTree.html
24+
</url>)
25+
2126
<dl>
2227
<dt>'FindSpanningTree'[$g$]
2328
<dd>finds a spanning tree of the graph $g$.
@@ -28,6 +33,7 @@ class FindSpanningTree(_NetworkXBuiltin):
2833
"""
2934

3035
options = DEFAULT_GRAPH_OPTIONS
36+
summary_text = "find a spanning tree"
3137

3238
def eval(self, graph, expression, evaluation: Evaluation, options: dict):
3339
"%(name)s[graph_, OptionsPattern[%(name)s]]"

pymathics/graph/parametric.py

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class BarbellGraph(_NetworkXBuiltin):
8686
:Barbell graph:https://en.wikipedia.org/wiki/Barbell_graph
8787
</url> (
8888
<url>
89-
:NetworkX:https://networkx.org/documentation/stable/reference/\
89+
:NetworkX:https://networkx.org/documentation/networkx-2.8.8/reference/\
9090
generated/networkx.generators.classic.barbell_graph.html</url>
9191
)
9292
@@ -144,7 +144,7 @@ class BinomialTree(_NetworkXBuiltin):
144144
:Binomial tree:https://en.wikipedia.org/wiki/Binomial_tree
145145
</url> (
146146
<url>
147-
:NetworkX:https://networkx.org/documentation/stable/reference/\
147+
:NetworkX:https://networkx.org/documentation/networkx-2.8.8/reference/\
148148
generated/networkx.generators.classic.binomial_tree.html</url>,
149149
<url>
150150
:WMA:https://reference.wolfram.com/language/ref/BinomialTree.html
@@ -198,6 +198,9 @@ def eval(
198198

199199
class CompleteGraph(_NetworkXBuiltin):
200200
"""
201+
<url>
202+
:WMA:https://reference.wolfram.com/language/ref/CompleteGraph.html
203+
</url>
201204
<dl>
202205
<dt>'CompleteGraph[$n$]'
203206
<dd>Returns the complete graph with $n$ vertices, $K_n$.
@@ -226,7 +229,12 @@ def eval_multipartite(self, n, evaluation: Evaluation, options: dict):
226229

227230

228231
class CompleteKaryTree(_NetworkXBuiltin):
229-
"""<dl>
232+
"""
233+
<url>
234+
:K-ary Tree:https://en.wikipedia.org/wiki/M-ary_tree
235+
</url>
236+
237+
<dl>
230238
<dt>'CompleteKaryTree[$n$, $k$]'
231239
<dd>Creates a complete $k$-ary tree of $n$ levels.
232240
</dl>
@@ -269,10 +277,14 @@ def eval_2(self, n, expression, evaluation: Evaluation, options: dict):
269277

270278

271279
class CycleGraph(_NetworkXBuiltin):
272-
"""<dl>
273-
<dt>'CycleGraph[$n$]'
274-
<dd>Returns the cycle graph with $n$ vertices $C_n$.
275-
</dl>
280+
"""
281+
<url>:Cycle Graph:
282+
https://en.wikipedia.org/wiki/Cycle_graph</url>
283+
284+
<dl>
285+
<dt>'CycleGraph[$n$]'
286+
<dd>Returns the cycle graph with $n$ vertices $C_n$.
287+
</dl>
276288
277289
>> CycleGraph[5, PlotLabel -> "C_i"]
278290
= -Graph-
@@ -289,8 +301,13 @@ def eval(self, n: Integer, expression, evaluation: Evaluation, options: dict):
289301
return eval_hkn_harary(self, Integer(2), n, expression, evaluation, options)
290302

291303

304+
# It seems that this makes the same than CompleteKaryTree
292305
class FullRAryTree(_NetworkXBuiltin):
293306
"""
307+
<url>
308+
:K-ary Tree:https://en.wikipedia.org/wiki/M-ary_tree
309+
</url>
310+
294311
<dl>
295312
<dt>'FullRAryTree[$r$, $n$]'
296313
<dd>Creates a full $r$-ary tree of $n$ vertices.
@@ -321,6 +338,11 @@ def eval(self, r, n, expression, evaluation: Evaluation, options: dict):
321338

322339
class GraphAtlas(_NetworkXBuiltin):
323340
"""
341+
<url>:NetworkX:
342+
https://networkx.org/documentation/networkx-2.8.8/reference/\
343+
generated/networkx.generators.atlas.graph_atlas.html
344+
</url>
345+
324346
<dl>
325347
<dt>'GraphAtlas[$n$]'
326348
<dd>Returns graph number $i$ from the NetworkX's Graph \
@@ -357,6 +379,10 @@ def eval(self, n, expression, evaluation: Evaluation, options: dict):
357379

358380
class HknHararyGraph(_NetworkXBuiltin):
359381
"""
382+
<url>:NetworkX:
383+
https://networkx.org/documentation/networkx-2.8.8/reference\
384+
/generated/networkx.generators.harary_graph.hkn_harary_graph.html#hkn-harary-graph
385+
</url>
360386
<dl>
361387
<dt>'HknHararyGraph[$k$, $n$]'
362388
<dd>Returns the Harary graph with given node connectivity and node number.
@@ -387,6 +413,10 @@ def eval(self, k, n, expression, evaluation: Evaluation, options: dict):
387413

388414
class HmnHararyGraph(_NetworkXBuiltin):
389415
"""
416+
<url>:NetworkX:
417+
https://networkx.org/documentation/networkx-2.8.8/reference\
418+
/generated/networkx.generators.harary_graph.hnm_harary_graph.html
419+
</url>
390420
<dl>
391421
<dt>'HmnHararyGraph[$m$, $n$]'
392422
<dd>Returns the Harary graph with given numbers of nodes and edges.
@@ -437,6 +467,11 @@ def eval(self, n, m, expression, evaluation: Evaluation, options: dict):
437467

438468
class KaryTree(_NetworkXBuiltin):
439469
"""
470+
<url>
471+
:K-ary Tree:https://en.wikipedia.org/wiki/M-ary_tree
472+
</url>
473+
474+
440475
<dl>
441476
<dt>'KaryTree[$r$, $n$]'
442477
<dd>Creates binary tree of $n$ vertices.
@@ -478,6 +513,12 @@ def eval_with_k(
478513

479514
class LadderGraph(_NetworkXBuiltin):
480515
"""
516+
<url>
517+
:Ladder graph:https://en.wikipedia.org/wiki/Ladder_graph
518+
</url>(<url>:NetworkX:
519+
https://networkx.org/documentation/networkx-2.8.8/reference\
520+
/generated/networkx.generators.classic.ladder_graph.html
521+
</url>)
481522
<dl>
482523
<dt>'LadderGraph[$n$]'
483524
<dd>Returns the Ladder graph of length $n$.
@@ -514,6 +555,10 @@ def eval(
514555

515556
class PathGraph(_NetworkXBuiltin):
516557
"""
558+
<url>
559+
:Path graph:https://en.wikipedia.org/wiki/Path_graph
560+
</url>(<url>:WMA:https://reference.wolfram.com/language/ref/PathGraph.html
561+
</url>)
517562
<dl>
518563
<dt>'PathGraph[{$v_1$, $v_2$, ...}]'
519564
<dd>Returns a Graph with a path with vertices $v_i$ and \
@@ -542,6 +587,10 @@ def edges():
542587

543588
class RandomTree(_NetworkXBuiltin):
544589
"""
590+
<url>:NetworkX:
591+
https://networkx.org/documentation/networkx-2.8.8/reference\
592+
/generated/networkx.generators.trees.random_tree.html
593+
</url>
545594
<dl>
546595
<dt>'RandomTree[$n$]'
547596
<dd>Returns a uniformly random tree on $n$ nodes.
@@ -578,6 +627,16 @@ def eval(
578627

579628
class StarGraph(_NetworkXBuiltin):
580629
"""
630+
<url>
631+
:Path graph:https://en.wikipedia.org/wiki/Star_graph
632+
</url>(
633+
<url>:NetworkX:
634+
https://networkx.org/documentation/networkx-2.8.8/reference\
635+
/generated/networkx.generators.classic.star_graph.html
636+
</url>,
637+
<url>:WMA:
638+
https://reference.wolfram.com/language/ref/StarGraph.html
639+
</url>)
581640
<dl>
582641
<dt>'StarGraph[$n$]'
583642
<dd>Returns a star graph with $n$ vertices.

0 commit comments

Comments
 (0)