Skip to content

Commit 659f66f

Browse files
committed
Misc Tweaks
Start documenting Graph. Use existing graph layout in FindSpanningTree RandomGraph doc fix.
1 parent 1143fc6 commit 659f66f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

pymathics/graph/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ class DirectedEdge(Builtin):
760760
class UndirectedEdge(Builtin):
761761
"""
762762
<dl>
763-
<dt>'UndirectedEdge[$u$, $v$]'
763+
<dt>'UndirectedEdge[$u$, $v$]'
764764
<dd>an undirected edge between $u$ and $v$.
765765
</dl>
766766
@@ -779,6 +779,16 @@ class UndirectedEdge(Builtin):
779779

780780
class GraphAtom(AtomBuiltin):
781781
"""
782+
<dl>
783+
<dt>'Graph[{$e1, $e2, ...}]'
784+
<dd>returns a graph with edges $e_j$.
785+
</dl>
786+
787+
<dl>
788+
<dt>'Graph[{v1, v2, ...}, {$e1, $e2, ...}]'
789+
<dd>returns a graph with vertices $v_i$ and edges $e_j$.
790+
</dl>
791+
782792
>> Graph[{1->2, 2->3, 3->1}]
783793
= -Graph-
784794

pymathics/graph/algorithms.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ def apply(self, graph, expression, evaluation, options):
112112
# FIXME: put in edge to Graph conversion function?
113113
edges = [Expression("UndirectedEdge", u, v) for u, v in nx.minimum_spanning_edges(graph.G, data=False)]
114114
g = _create_graph(edges, [None] * len(edges), options)
115+
if not hasattr(g.G, "graph_layout"):
116+
if hasattr(graph.G, "graph_layout"):
117+
g.G.graph_layout = graph.G.graph_layout
118+
else:
119+
g.G.graph_layout = "tree"
115120
return g
116121

117122
class PlanarGraphQ(_NetworkXBuiltin):

pymathics/graph/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class RandomGraph(_NetworkXBuiltin):
530530
<dt>'RandomGraph[{$n$, $m$}]'
531531
<dd>Returns a pseudorandom graph with $n$ vertices and $m$ edges.
532532
533-
<dt>'RandomGraph[$n$, $m$, $k$]'
533+
<dt>'RandomGraph[{$n$, $m$}, $k$]'
534534
<dd>Returns list of $k$ RandomGraph[{$n$, $m$}].
535535
</dl>
536536
"""

0 commit comments

Comments
 (0)