Skip to content

Commit a75ce74

Browse files
committed
Make a pass over parametric graph section..
Some type-checking corrections were made and some bugs found from this fixed.
1 parent d3780b2 commit a75ce74

File tree

4 files changed

+110
-115
lines changed

4 files changed

+110
-115
lines changed

pymathics/graph/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
VertexList,
6161
)
6262

63-
from pymathics.graph.centralities import(
63+
from pymathics.graph.centralities import (
6464
BetweennessCentrality,
6565
ClosenessCentrality,
6666
DegreeCentrality,
@@ -86,7 +86,6 @@
8686
CompleteGraph,
8787
CompleteKaryTree,
8888
CycleGraph,
89-
FullRAryTree,
9089
GraphAtlas,
9190
HknHararyGraph,
9291
HmnHararyGraph,
@@ -144,7 +143,6 @@
144143
"FindShortestPath",
145144
"FindSpanningTree",
146145
"FindVertexCut",
147-
"FullRAryTree",
148146
"Graph",
149147
"GraphAtlas",
150148
"GraphAtom",

pymathics/graph/base.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def graph_helper(
8686
root: Optional[int] = None,
8787
*args,
8888
**kwargs,
89-
) -> Optional[Callable]:
89+
) -> Optional["Graph"]:
9090
should_digraph = can_digraph and has_directed_option(options)
9191
try:
9292
G = (
@@ -97,7 +97,11 @@ def graph_helper(
9797
except MemoryError:
9898
evaluation.message("Graph", "mem", evaluation)
9999
return None
100-
if graph_layout and not options["System`GraphLayout"].get_string_value():
100+
if (
101+
graph_layout and not options["System`GraphLayout"].get_string_value()
102+
if "System`GraphLayout" in options
103+
else False
104+
):
101105
options["System`GraphLayout"] = String(graph_layout)
102106

103107
g = Graph(G)
@@ -380,6 +384,19 @@ def __init__(self, Gr, **kwargs):
380384
self.G = Gr
381385
self.mixed = kwargs.get("mixed", False)
382386

387+
# Number of nodes
388+
self.n: Optional[int] = None
389+
390+
# Here we define types that appear on some, but not all
391+
# graphs. So these are optional, which we given an initial
392+
# value of None
393+
394+
# Some graphs has a second int parameter like HknHarary
395+
self.n: Optional[int] = None
396+
397+
# Trees have a root
398+
self.root: Optional[int] = None
399+
383400
def __hash__(self):
384401
return hash(("Pymathics`Graph", self.G))
385402

pymathics/graph/eval/parametric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def eval_full_rary_tree(
3636
self, r: Integer, n: Integer, expression, evaluation: Evaluation, options: dict
3737
) -> Optional[Graph]:
3838
"""
39-
Call networkx to get a full_raray_tree using parameters, ``r`` and ``t``.
39+
Call networkx to get a full_rary_tree using parameters, ``r`` and ``t``.
4040
"""
4141
py_r = r.value
4242

0 commit comments

Comments
 (0)