File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed
Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 1+ from mathics .core .symbols import SymbolConstant , SymbolFalse , SymbolTrue
2+
3+ import networkx as nx
4+ from pymathics .graph .base import Graph
5+
6+
7+ def eval_TreeGraphQ (g : Graph ) -> SymbolConstant :
8+ """
9+ Returns SymbolTrue if g is a (networkx) tree and SymbolFalse
10+ otherwise.
11+ """
12+ if not isinstance (g , Graph ):
13+ return SymbolFalse
14+ return SymbolTrue if nx .is_tree (g .G ) else SymbolFalse
Original file line number Diff line number Diff line change 1+ """
2+ Trees
3+ """
14import networkx as nx
25from mathics .core .atoms import Atom
36from mathics .core .evaluation import Evaluation
4- from mathics .core .symbols import SymbolConstant , SymbolFalse , SymbolTrue
7+ from mathics .core .symbols import SymbolConstant
58
69from pymathics .graph .base import (
710 DEFAULT_GRAPH_OPTIONS ,
8- Graph ,
911 _graph_from_list ,
1012 _NetworkXBuiltin ,
1113)
14+ from pymathics .graph .eval .tree import eval_TreeGraphQ
1215
1316DEFAULT_TREE_OPTIONS = {
1417 ** DEFAULT_GRAPH_OPTIONS ,
1821from mathics .builtin .base import AtomBuiltin
1922
2023
21- def eval_TreeGraphQ (g : Graph ) -> SymbolConstant :
22- """
23- Returns SymbolTrue if g is a (networkx) tree and SymbolFalse
24- otherwise.
25- """
26- if not isinstance (g , Graph ):
27- return SymbolFalse
28- return SymbolTrue if nx .is_tree (g .G ) else SymbolFalse
29-
30-
3124# FIXME: do we need to have TreeGraphAtom and TreeGraph?
3225# Can't these be combined into one?
3326class TreeGraphAtom (AtomBuiltin ):
You can’t perform that action at this time.
0 commit comments