Skip to content

Commit 4bd1218

Browse files
committed
second round
1 parent 8711ccd commit 4bd1218

File tree

6 files changed

+89
-1
lines changed

6 files changed

+89
-1
lines changed

pymathics/graph/components.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
class ConnectedComponents(_NetworkXBuiltin):
1717
"""
18+
<url>
19+
:WMA:https://reference.wolfram.com/language/ref/ConnectedComponents.html
20+
</url>
21+
1822
<dl>
1923
<dt>'ConnectedComponents'[$g$]
2024
<dd> gives the connected components of the graph $g$.
@@ -39,6 +43,8 @@ class ConnectedComponents(_NetworkXBuiltin):
3943
= ...
4044
"""
4145

46+
summary_text = "list the connected components"
47+
4248
def eval(
4349
self, graph, expression, evaluation: Evaluation, options: dict
4450
) -> Optional[ListExpression]:
@@ -76,6 +82,10 @@ def eval(
7682

7783
class WeaklyConnectedComponents(_NetworkXBuiltin):
7884
"""
85+
<url>
86+
:WMA:https://reference.wolfram.com/language/ref/WeaklyConnectedComponents.html
87+
</url>
88+
7989
<dl>
8090
<dt>'WeaklyConnectedComponents'[$g$]
8191
<dd> gives the weakly connected components of the graph $g$.
@@ -100,6 +110,8 @@ class WeaklyConnectedComponents(_NetworkXBuiltin):
100110
= {{1, 2, 3, 4, 5}, {6, 7, 8}}
101111
"""
102112

113+
summary_text = "list the weakly connected components"
114+
103115
def eval(self, graph, expression, evaluation: Evaluation, options):
104116
"WeaklyConnectedComponents[graph_, OptionsPattern[WeaklyConnectedComponents]]"
105117
graph = self._build_graph(graph, evaluation, options, expression)

pymathics/graph/curated.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
class GraphData(_NetworkXBuiltin):
1212
"""
13+
<url>
14+
:WMA:https://reference.wolfram.com/language/ref/GraphData.html
15+
</url>
16+
1317
<dl>
1418
<dt>'GraphData[$name$]'
1519
<dd>Returns a graph with the specified name.
@@ -19,6 +23,8 @@ class GraphData(_NetworkXBuiltin):
1923
= -Graph-
2024
"""
2125

26+
summary_text = "create a graph by name"
27+
2228
def eval(self, name, expression, evaluation: Evaluation, options: dict) -> Graph:
2329
"GraphData[name_String, OptionsPattern[GraphData]]"
2430
py_name = name.get_string_value()

pymathics/graph/parametric.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
class BalancedTree(_NetworkXBuiltin):
3232
"""
33+
<url>
34+
:WMA:https://reference.wolfram.com/language/ref/BalancedTree.html
35+
</url>
36+
3337
<dl>
3438
<dt>'BalancedTree[$r$, $h$]'
3539
<dd>Returns the perfectly balanced $r$-ary tree of height $h$.
@@ -50,6 +54,7 @@ class BalancedTree(_NetworkXBuiltin):
5054
}
5155

5256
options = DEFAULT_TREE_OPTIONS
57+
summary_text = "build a balanced tree graph"
5358

5459
def eval(
5560
self, r: Integer, h: Integer, expression, evaluation: Evaluation, options: dict
@@ -77,6 +82,14 @@ def eval(
7782

7883
class BarbellGraph(_NetworkXBuiltin):
7984
"""
85+
<url>
86+
:Barbell graph:https://en.wikipedia.org/wiki/Barbell_graph
87+
</url> (
88+
<url>
89+
:NetworkX:https://networkx.org/documentation/stable/reference/\
90+
generated/networkx.generators.classic.barbell_graph.html</url>
91+
)
92+
8093
<dl>
8194
<dt>'BarbellGraph[$m1$, $m2$]'
8295
<dd>Barbell Graph: two complete graphs connected by a path.
@@ -91,6 +104,7 @@ class BarbellGraph(_NetworkXBuiltin):
91104
"ilsmp": "Expected a non-negative integer at position 1 in ``.",
92105
"ilsmp2": "Expected a non-negative integer at position 2 in ``.",
93106
}
107+
summary_text = "build a n-m Barbell graph"
94108

95109
def eval(
96110
self,
@@ -126,6 +140,17 @@ def eval(
126140

127141
class BinomialTree(_NetworkXBuiltin):
128142
"""
143+
<url>
144+
:Binomial tree:https://en.wikipedia.org/wiki/Binomial_tree
145+
</url> (
146+
<url>
147+
:NetworkX:https://networkx.org/documentation/stable/reference/\
148+
generated/networkx.generators.classic.binomial_tree.html</url>,
149+
<url>
150+
:WMA:https://reference.wolfram.com/language/ref/BinomialTree.html
151+
</url>
152+
)
153+
129154
<dl>
130155
<dt>'BinomialTree[$n$]'
131156
<dd>Returns the Binomial Tree of order $n$.
@@ -151,6 +176,7 @@ class BinomialTree(_NetworkXBuiltin):
151176
"ilsmp": "Expected a non-negative integer at position 1 in ``.",
152177
"mem": "Out of memory",
153178
}
179+
summary_text = "build a binomial tree"
154180

155181
def eval(
156182
self, n: Integer, expression, evaluation: Evaluation, options: dict
@@ -185,6 +211,8 @@ class CompleteGraph(_NetworkXBuiltin):
185211
"ilsmp": "Expected a positive integer at position 1 in ``.",
186212
}
187213

214+
summary_text = "build a completely connected graph"
215+
188216
def eval(self, n: Integer, expression, evaluation: Evaluation, options: dict):
189217
"%(name)s[n_Integer, OptionsPattern[%(name)s]]"
190218
return eval_complete_graph(self, n, expression, evaluation, options)
@@ -215,6 +243,7 @@ class CompleteKaryTree(_NetworkXBuiltin):
215243
"""
216244

217245
options = DEFAULT_TREE_OPTIONS
246+
summary_text = "build a complete k-ary tree"
218247

219248
def eval(self, k, n, expression, evaluation: Evaluation, options: dict):
220249
"%(name)s[n_Integer, k_Integer, OptionsPattern[%(name)s]]"
@@ -249,6 +278,8 @@ class CycleGraph(_NetworkXBuiltin):
249278
= -Graph-
250279
"""
251280

281+
summary_text = "build a cycle graph"
282+
252283
def eval(self, n: Integer, expression, evaluation: Evaluation, options: dict):
253284
"%(name)s[n_Integer, OptionsPattern[%(name)s]]"
254285
n_int = n.get_int_value()
@@ -259,7 +290,8 @@ def eval(self, n: Integer, expression, evaluation: Evaluation, options: dict):
259290

260291

261292
class FullRAryTree(_NetworkXBuiltin):
262-
"""<dl>
293+
"""
294+
<dl>
263295
<dt>'FullRAryTree[$r$, $n$]'
264296
<dd>Creates a full $r$-ary tree of $n$ vertices.
265297
</dl>
@@ -280,6 +312,7 @@ class FullRAryTree(_NetworkXBuiltin):
280312
}
281313

282314
options = DEFAULT_TREE_OPTIONS
315+
summary_text = "build a full r-ary tree"
283316

284317
def eval(self, r, n, expression, evaluation: Evaluation, options: dict):
285318
"%(name)s[r_Integer, n_Integer, OptionsPattern[%(name)s]]"
@@ -301,6 +334,7 @@ class GraphAtlas(_NetworkXBuiltin):
301334
messages = {
302335
"ilsmp": "Expected a positive integer at position 1 in ``.",
303336
}
337+
summary_text = "build the i-esim graph from the Networkx atlas"
304338

305339
def eval(self, n, expression, evaluation: Evaluation, options: dict):
306340
"%(name)s[n_Integer, OptionsPattern[%(name)s]]"
@@ -343,6 +377,7 @@ class HknHararyGraph(_NetworkXBuiltin):
343377
"ilsmp": "Expected a non-negative integer at position 1 in ``.",
344378
"ilsmp2": "Expected a non-negative integer at position 2 in ``.",
345379
}
380+
summary_text = "build a Hkn Harary graph"
346381

347382
def eval(self, k, n, expression, evaluation: Evaluation, options: dict):
348383
"%(name)s[k_Integer, n_Integer, OptionsPattern[%(name)s]]"
@@ -372,6 +407,8 @@ class HmnHararyGraph(_NetworkXBuiltin):
372407
"ilsmp2": "Expected a non-negative integer at position 2 in ``.",
373408
}
374409

410+
summary_text = "build a Hmn Harary graph"
411+
375412
def eval(self, n, m, expression, evaluation: Evaluation, options: dict):
376413
"%(name)s[n_Integer, m_Integer, OptionsPattern[%(name)s]]"
377414
py_n = n.value
@@ -423,6 +460,7 @@ class KaryTree(_NetworkXBuiltin):
423460
}
424461

425462
options = DEFAULT_TREE_OPTIONS
463+
summary_text = "build a Kary tree"
426464

427465
def eval(
428466
self, n: Integer, expression, evaluation: Evaluation, options: dict
@@ -451,6 +489,7 @@ class LadderGraph(_NetworkXBuiltin):
451489
messages = {
452490
"ilsmp": "Expected a positive integer at position 1 in ``.",
453491
}
492+
summary_text = "build a ladder tree"
454493

455494
def eval(
456495
self, n: Integer, expression, evaluation: Evaluation, options: dict
@@ -483,6 +522,8 @@ class PathGraph(_NetworkXBuiltin):
483522
= -Graph-
484523
"""
485524

525+
summary_text = "build a path graph"
526+
486527
def eval(self, e, evaluation: Evaluation, options: dict) -> Graph:
487528
"PathGraph[e_List, OptionsPattern[PathGraph]]"
488529
elements = e.elements
@@ -514,6 +555,8 @@ class RandomTree(_NetworkXBuiltin):
514555
"ilsmp": "Expected a non-negative integer at position 1 in ``.",
515556
}
516557

558+
summary_text = "build a random tree"
559+
517560
def eval(
518561
self, n: Integer, expression, evaluation: Evaluation, options: dict
519562
) -> Graph:
@@ -546,6 +589,7 @@ class StarGraph(_NetworkXBuiltin):
546589
messages = {
547590
"ilsmp": "Expected a positive integer at position 1 in ``.",
548591
}
592+
summary_text = "build a star graph"
549593

550594
def eval(
551595
self, n: Integer, expression, evaluation: Evaluation, options: dict

pymathics/graph/random.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
class RandomGraph(_NetworkXBuiltin):
2121
"""
22+
<url>
23+
:WMA:https://reference.wolfram.com/language/ref/RandomGraph.html
24+
</url>
25+
2226
<dl>
2327
<dt>'RandomGraph[{$n$, $m$}]'
2428
<dd>Returns a pseudorandom graph with $n$ vertices and $m$ edges.
@@ -28,6 +32,8 @@ class RandomGraph(_NetworkXBuiltin):
2832
</dl>
2933
"""
3034

35+
summary_text = "build a random graph"
36+
3137
def _generate(
3238
self, n: Integer, m: Integer, k: Integer, evaluation: Evaluation, options: dict
3339
) -> Graph:

pymathics/graph/structured.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
class PathGraph(_NetworkXBuiltin):
1515
"""
16+
<url>
17+
:WMA:https://reference.wolfram.com/language/ref/PathGraph.html
18+
</url>
19+
1620
<dl>
1721
<dt>'PathGraph[{$v_1$, $v_2$, ...}]'
1822
<dd>Returns a Graph with a path with vertices $v_i$ and edges between $v-i$ and $v_i+1$ .
@@ -21,6 +25,8 @@ class PathGraph(_NetworkXBuiltin):
2125
= -Graph-
2226
"""
2327

28+
summary_text = "create a graph from a path"
29+
2430
def eval(self, e, evaluation: Evaluation, options: dict) -> Graph:
2531
"PathGraph[e_List, OptionsPattern[PathGraph]]"
2632
elements = e.elements
@@ -38,6 +44,16 @@ def edges():
3844

3945
class TreeGraph(Graph):
4046
"""
47+
<url>
48+
:WMA:https://reference.wolfram.com/language/ref/TreeGraph.html
49+
</url>
50+
51+
<dl>
52+
<dt>'TreeGraph[{$edge_1$, $edge_2$, ...}]'
53+
<dd>create a tree-like from a list of edges.
54+
</dl>
55+
56+
4157
>> TreeGraph[{1->2, 2->3, 2->4}]
4258
= -Graph-
4359
@@ -49,6 +65,8 @@ class TreeGraph(Graph):
4965
"notree": "Graph is not a tree.",
5066
}
5167

68+
summary_text = "build a tree graph"
69+
5270
def __init__(self, G, **kwargs):
5371
super(Graph, self).__init__()
5472
if not nx.is_tree(G):

pymathics/graph/tree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class TreeGraphQ(_NetworkXBuiltin):
7272
= False
7373
"""
7474

75+
summary_text = "test for a tree-like graph"
76+
7577
def eval(
7678
self, g, expression, evaluation: Evaluation, options: dict
7779
) -> SymbolConstant:

0 commit comments

Comments
 (0)