first approx to grapher

This commit is contained in:
2020-05-20 12:32:17 +02:00
parent 6ebd0f9be3
commit c0ef71f139
10 changed files with 533 additions and 83 deletions

View File

@@ -4,14 +4,13 @@ __copyright__ = "Copyright 2020, Ricardo Montañana Gómez"
__license__ = "MIT"
__version__ = "0.9"
Inorder iterator for the binary tree of Snodes
Uses LinearSVC
'''
from trees.Snode import Snode
class Siterator:
"""Inorder iterator
"""Stree preorder iterator
"""
def __init__(self, tree: Snode):
@@ -22,13 +21,13 @@ class Siterator:
return self
def _push(self, node: Snode):
while (node is not None):
self._stack.insert(0, node)
node = node.get_down()
if node is not None:
self._stack.append(node)
def __next__(self) -> Snode:
if len(self._stack) == 0:
raise StopIteration()
node = self._stack.pop()
self._push(node.get_up())
self._push(node.get_down())
return node