memory-graph 0.3.16__tar.gz → 0.3.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memory_graph-0.3.16/memory_graph.egg-info → memory_graph-0.3.17}/PKG-INFO +20 -29
- {memory_graph-0.3.16 → memory_graph-0.3.17}/README.md +19 -28
- memory_graph-0.3.17/images/bin_tree.png +0 -0
- memory_graph-0.3.17/images/bin_tree.py +38 -0
- memory_graph-0.3.17/images/bin_tree2.py +31 -0
- memory_graph-0.3.17/images/bin_tree2.py~ +31 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging01.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging02.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging03.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging04.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging05.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging06.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial01.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial02.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial03.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial04.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial05.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial06.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial07.png +0 -0
- memory_graph-0.3.17/images/memory_graph.pdf +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set1.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set10.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set11.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set12.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set13.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set14.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set15.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set16.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set17.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set18.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set19.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set2.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set20.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set21.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set22.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set3.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set4.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set5.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set6.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set7.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set8.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set9.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/__init__.py +1 -1
- {memory_graph-0.3.16 → memory_graph-0.3.17/memory_graph.egg-info}/PKG-INFO +20 -29
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph.egg-info/SOURCES.txt +3 -1
- {memory_graph-0.3.16 → memory_graph-0.3.17}/setup.py +1 -1
- memory_graph-0.3.16/images/bin_tree.png +0 -0
- memory_graph-0.3.16/images/bin_tree.py +0 -47
- memory_graph-0.3.16/images/memory_graph.gv +0 -20
- {memory_graph-0.3.16 → memory_graph-0.3.17}/LICENSE.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/MANIFEST.in +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/TODO.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/.ipynb_checkpoints/jupyter_example-checkpoint.ipynb +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/add_one.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/add_one.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree.py~ +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_base.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_dir.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_fail.gv +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_fail.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_key_value.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_linear.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/avltree_table.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/copies.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/copies.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/copy_method.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/copy_method.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/create_gif.sh +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/create_images.sh +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debug_vscode.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging.gif +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/debugging.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/extension_numpy.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/extension_numpy.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/extension_pandas.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/extension_pandas.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial.gif +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/factorial.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/hash_set.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/hash_set.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/highlight.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/highlight.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/immutable.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/immutable1.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/immutable2.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/ipython.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/jupyter_example.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/linked_list.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/linked_list.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/many_types.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/many_types.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/memory_graph.gv.pdf +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/mutable.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/mutable1.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/mutable2.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/my_graph.gv +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/my_graph.pdf +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/name_rebinding.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/not_node_types.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/not_node_types.py~ +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/not_node_types1.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/not_node_types2.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set.gif +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/power_set.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/pyodide.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/rebinding1.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/rebinding2.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/images/uva.png +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/install.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/config.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/config_default.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/config_helpers.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/extension_numpy.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/extension_pandas.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/html_table.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/list_view.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/memory_to_nodes.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/node_base.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/node_key_value.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/node_linear.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/node_table.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/sequence.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/slicer.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/slices.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/slices_iterator.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/slices_table_iterator.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_max_graph_depth.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_memory_graph.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_memory_to_nodes.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_sequence.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_slicer.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_slices.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/test_slices_iterator.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph/utils.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph.egg-info/dependency_links.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph.egg-info/requires.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/memory_graph.egg-info/top_level.txt +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/setup.cfg +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/src/auto_memory_graph.py +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/src/jupyter_example.ipynb +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/src/pyodide.html +0 -0
- {memory_graph-0.3.16 → memory_graph-0.3.17}/uml/memory_graph.uxf +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.17
|
|
4
4
|
Summary: Generate intuitive graphs of your Python data, great for debugging and understanding complex relationships.
|
|
5
5
|
Home-page: https://github.com/bterwijn/memory_graph
|
|
6
6
|
Author: Bas Terwijn
|
|
@@ -430,7 +430,7 @@ class LinkedList:
|
|
|
430
430
|
new_node.next = self.head
|
|
431
431
|
self.head.prev = new_node
|
|
432
432
|
self.head = new_node
|
|
433
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
433
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
434
434
|
|
|
435
435
|
linked_list = LinkedList()
|
|
436
436
|
n = 100
|
|
@@ -446,42 +446,33 @@ import memory_graph as mg
|
|
|
446
446
|
import random
|
|
447
447
|
random.seed(0) # use same random numbers each run
|
|
448
448
|
|
|
449
|
-
class Node:
|
|
450
|
-
|
|
451
|
-
def __init__(self, value):
|
|
452
|
-
self.smaller = None
|
|
453
|
-
self.value = value
|
|
454
|
-
self.larger = None
|
|
455
|
-
|
|
456
449
|
class BinTree:
|
|
457
450
|
|
|
458
|
-
def __init__(self):
|
|
459
|
-
self.
|
|
451
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
452
|
+
self.smaller = smaller
|
|
453
|
+
self.value = value
|
|
454
|
+
self.larger = larger
|
|
460
455
|
|
|
461
|
-
def
|
|
462
|
-
if
|
|
463
|
-
|
|
464
|
-
|
|
456
|
+
def add(self, value):
|
|
457
|
+
if self.value is None:
|
|
458
|
+
self.value = value
|
|
459
|
+
elif value < self.value:
|
|
460
|
+
if self.smaller is None:
|
|
461
|
+
self.smaller = BinTree(value)
|
|
465
462
|
else:
|
|
466
|
-
self.
|
|
463
|
+
self.smaller.add(value)
|
|
467
464
|
else:
|
|
468
|
-
if
|
|
469
|
-
|
|
465
|
+
if self.larger is None:
|
|
466
|
+
self.larger = BinTree(value)
|
|
470
467
|
else:
|
|
471
|
-
self.
|
|
472
|
-
mg.block(mg.show,
|
|
473
|
-
|
|
474
|
-
def add(self, value):
|
|
475
|
-
if self.root is None:
|
|
476
|
-
self.root = Node(value)
|
|
477
|
-
else:
|
|
478
|
-
self.add_recursive(value, self.root)
|
|
468
|
+
self.larger.add(value)
|
|
469
|
+
mg.block(mg.show, mg.stack()) # <--- draw stack
|
|
479
470
|
|
|
480
471
|
tree = BinTree()
|
|
481
472
|
n = 100
|
|
482
473
|
for i in range(n):
|
|
483
|
-
|
|
484
|
-
tree.add(
|
|
474
|
+
value = random.randrange(n)
|
|
475
|
+
tree.add(value)
|
|
485
476
|
```
|
|
486
477
|

|
|
487
478
|
|
|
@@ -502,7 +493,7 @@ class HashSet:
|
|
|
502
493
|
self.buckets[index] = []
|
|
503
494
|
bucket = self.buckets[index]
|
|
504
495
|
bucket.append(value)
|
|
505
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
496
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
506
497
|
|
|
507
498
|
def contains(self, value):
|
|
508
499
|
index = hash(value) % len(self.buckets)
|
|
@@ -411,7 +411,7 @@ class LinkedList:
|
|
|
411
411
|
new_node.next = self.head
|
|
412
412
|
self.head.prev = new_node
|
|
413
413
|
self.head = new_node
|
|
414
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
414
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
415
415
|
|
|
416
416
|
linked_list = LinkedList()
|
|
417
417
|
n = 100
|
|
@@ -427,42 +427,33 @@ import memory_graph as mg
|
|
|
427
427
|
import random
|
|
428
428
|
random.seed(0) # use same random numbers each run
|
|
429
429
|
|
|
430
|
-
class Node:
|
|
431
|
-
|
|
432
|
-
def __init__(self, value):
|
|
433
|
-
self.smaller = None
|
|
434
|
-
self.value = value
|
|
435
|
-
self.larger = None
|
|
436
|
-
|
|
437
430
|
class BinTree:
|
|
438
431
|
|
|
439
|
-
def __init__(self):
|
|
440
|
-
self.
|
|
432
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
433
|
+
self.smaller = smaller
|
|
434
|
+
self.value = value
|
|
435
|
+
self.larger = larger
|
|
441
436
|
|
|
442
|
-
def
|
|
443
|
-
if
|
|
444
|
-
|
|
445
|
-
|
|
437
|
+
def add(self, value):
|
|
438
|
+
if self.value is None:
|
|
439
|
+
self.value = value
|
|
440
|
+
elif value < self.value:
|
|
441
|
+
if self.smaller is None:
|
|
442
|
+
self.smaller = BinTree(value)
|
|
446
443
|
else:
|
|
447
|
-
self.
|
|
444
|
+
self.smaller.add(value)
|
|
448
445
|
else:
|
|
449
|
-
if
|
|
450
|
-
|
|
446
|
+
if self.larger is None:
|
|
447
|
+
self.larger = BinTree(value)
|
|
451
448
|
else:
|
|
452
|
-
self.
|
|
453
|
-
mg.block(mg.show,
|
|
454
|
-
|
|
455
|
-
def add(self, value):
|
|
456
|
-
if self.root is None:
|
|
457
|
-
self.root = Node(value)
|
|
458
|
-
else:
|
|
459
|
-
self.add_recursive(value, self.root)
|
|
449
|
+
self.larger.add(value)
|
|
450
|
+
mg.block(mg.show, mg.stack()) # <--- draw stack
|
|
460
451
|
|
|
461
452
|
tree = BinTree()
|
|
462
453
|
n = 100
|
|
463
454
|
for i in range(n):
|
|
464
|
-
|
|
465
|
-
tree.add(
|
|
455
|
+
value = random.randrange(n)
|
|
456
|
+
tree.add(value)
|
|
466
457
|
```
|
|
467
458
|

|
|
468
459
|
|
|
@@ -483,7 +474,7 @@ class HashSet:
|
|
|
483
474
|
self.buckets[index] = []
|
|
484
475
|
bucket = self.buckets[index]
|
|
485
476
|
bucket.append(value)
|
|
486
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
477
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
487
478
|
|
|
488
479
|
def contains(self, value):
|
|
489
480
|
index = hash(value) % len(self.buckets)
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This file is part of memory_graph.
|
|
2
|
+
# Copyright (c) 2023, Bas Terwijn.
|
|
3
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
|
|
5
|
+
import memory_graph as mg
|
|
6
|
+
import random
|
|
7
|
+
random.seed(0) # use same random numbers each run
|
|
8
|
+
|
|
9
|
+
class BinTree:
|
|
10
|
+
|
|
11
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
12
|
+
self.smaller = smaller
|
|
13
|
+
self.value = value
|
|
14
|
+
self.larger = larger
|
|
15
|
+
|
|
16
|
+
def add(self, value):
|
|
17
|
+
if self.value is None:
|
|
18
|
+
self.value = value
|
|
19
|
+
elif value < self.value:
|
|
20
|
+
if self.smaller is None:
|
|
21
|
+
self.smaller = BinTree(value)
|
|
22
|
+
else:
|
|
23
|
+
self.smaller.add(value)
|
|
24
|
+
else:
|
|
25
|
+
if self.larger is None:
|
|
26
|
+
self.larger = BinTree(value)
|
|
27
|
+
else:
|
|
28
|
+
self.larger.add(value)
|
|
29
|
+
if value == 51:
|
|
30
|
+
mg.render(mg.stack(), f"bin_tree.png")
|
|
31
|
+
exit(0)
|
|
32
|
+
|
|
33
|
+
tree = BinTree()
|
|
34
|
+
n = 100
|
|
35
|
+
for i in range(n):
|
|
36
|
+
value = random.randrange(n)
|
|
37
|
+
tree.add(value)
|
|
38
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import memory_graph as mg
|
|
2
|
+
import random
|
|
3
|
+
random.seed(0) # use same random numbers each run
|
|
4
|
+
|
|
5
|
+
class BinTree:
|
|
6
|
+
|
|
7
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
8
|
+
self.smaller = smaller
|
|
9
|
+
self.value = value
|
|
10
|
+
self.larger = larger
|
|
11
|
+
|
|
12
|
+
def add(self, value):
|
|
13
|
+
if self.value is None:
|
|
14
|
+
self.value = value
|
|
15
|
+
elif value < self.value:
|
|
16
|
+
if self.smaller is None:
|
|
17
|
+
self.smaller = BinTree(value)
|
|
18
|
+
else:
|
|
19
|
+
self.smaller.add(value)
|
|
20
|
+
else:
|
|
21
|
+
if self.larger is None:
|
|
22
|
+
self.larger = BinTree(value)
|
|
23
|
+
else:
|
|
24
|
+
self.larger.add(value)
|
|
25
|
+
mg.block(mg.show, mg.stack())
|
|
26
|
+
|
|
27
|
+
tree = BinTree()
|
|
28
|
+
n = 100
|
|
29
|
+
for i in range(n):
|
|
30
|
+
value = random.randrange(n)
|
|
31
|
+
tree.add(value)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import memory_graph as mg
|
|
2
|
+
import random
|
|
3
|
+
random.seed(0) # use same random numbers each run
|
|
4
|
+
|
|
5
|
+
class BinTree:
|
|
6
|
+
|
|
7
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
8
|
+
self.smaller = smaller
|
|
9
|
+
self.value = value
|
|
10
|
+
self.larger = larger
|
|
11
|
+
|
|
12
|
+
def add(self, value):
|
|
13
|
+
if self.value is None:
|
|
14
|
+
self.value = value
|
|
15
|
+
elif value < self.value:
|
|
16
|
+
if self.smaller is None:
|
|
17
|
+
self.smaller = BinTree(value)
|
|
18
|
+
else:
|
|
19
|
+
self.smaller.add(value)
|
|
20
|
+
else:
|
|
21
|
+
if self.larger is None:
|
|
22
|
+
self.larger = BinTree(value)
|
|
23
|
+
else:
|
|
24
|
+
self.larger.add(value)
|
|
25
|
+
mg.block(mg.render, mg.stack(), f"bin_tree.png")
|
|
26
|
+
|
|
27
|
+
tree = BinTree()
|
|
28
|
+
n = 100
|
|
29
|
+
for i in range(n):
|
|
30
|
+
value = random.randrange(n)
|
|
31
|
+
tree.add(value)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.17
|
|
4
4
|
Summary: Generate intuitive graphs of your Python data, great for debugging and understanding complex relationships.
|
|
5
5
|
Home-page: https://github.com/bterwijn/memory_graph
|
|
6
6
|
Author: Bas Terwijn
|
|
@@ -430,7 +430,7 @@ class LinkedList:
|
|
|
430
430
|
new_node.next = self.head
|
|
431
431
|
self.head.prev = new_node
|
|
432
432
|
self.head = new_node
|
|
433
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
433
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
434
434
|
|
|
435
435
|
linked_list = LinkedList()
|
|
436
436
|
n = 100
|
|
@@ -446,42 +446,33 @@ import memory_graph as mg
|
|
|
446
446
|
import random
|
|
447
447
|
random.seed(0) # use same random numbers each run
|
|
448
448
|
|
|
449
|
-
class Node:
|
|
450
|
-
|
|
451
|
-
def __init__(self, value):
|
|
452
|
-
self.smaller = None
|
|
453
|
-
self.value = value
|
|
454
|
-
self.larger = None
|
|
455
|
-
|
|
456
449
|
class BinTree:
|
|
457
450
|
|
|
458
|
-
def __init__(self):
|
|
459
|
-
self.
|
|
451
|
+
def __init__(self, value=None, smaller=None, larger=None):
|
|
452
|
+
self.smaller = smaller
|
|
453
|
+
self.value = value
|
|
454
|
+
self.larger = larger
|
|
460
455
|
|
|
461
|
-
def
|
|
462
|
-
if
|
|
463
|
-
|
|
464
|
-
|
|
456
|
+
def add(self, value):
|
|
457
|
+
if self.value is None:
|
|
458
|
+
self.value = value
|
|
459
|
+
elif value < self.value:
|
|
460
|
+
if self.smaller is None:
|
|
461
|
+
self.smaller = BinTree(value)
|
|
465
462
|
else:
|
|
466
|
-
self.
|
|
463
|
+
self.smaller.add(value)
|
|
467
464
|
else:
|
|
468
|
-
if
|
|
469
|
-
|
|
465
|
+
if self.larger is None:
|
|
466
|
+
self.larger = BinTree(value)
|
|
470
467
|
else:
|
|
471
|
-
self.
|
|
472
|
-
mg.block(mg.show,
|
|
473
|
-
|
|
474
|
-
def add(self, value):
|
|
475
|
-
if self.root is None:
|
|
476
|
-
self.root = Node(value)
|
|
477
|
-
else:
|
|
478
|
-
self.add_recursive(value, self.root)
|
|
468
|
+
self.larger.add(value)
|
|
469
|
+
mg.block(mg.show, mg.stack()) # <--- draw stack
|
|
479
470
|
|
|
480
471
|
tree = BinTree()
|
|
481
472
|
n = 100
|
|
482
473
|
for i in range(n):
|
|
483
|
-
|
|
484
|
-
tree.add(
|
|
474
|
+
value = random.randrange(n)
|
|
475
|
+
tree.add(value)
|
|
485
476
|
```
|
|
486
477
|

|
|
487
478
|
|
|
@@ -502,7 +493,7 @@ class HashSet:
|
|
|
502
493
|
self.buckets[index] = []
|
|
503
494
|
bucket = self.buckets[index]
|
|
504
495
|
bucket.append(value)
|
|
505
|
-
mg.block(mg.show, locals()) # <--- draw
|
|
496
|
+
mg.block(mg.show, locals()) # <--- draw locals
|
|
506
497
|
|
|
507
498
|
def contains(self, value):
|
|
508
499
|
index = hash(value) % len(self.buckets)
|
|
@@ -17,6 +17,8 @@ images/avltree_linear.png
|
|
|
17
17
|
images/avltree_table.png
|
|
18
18
|
images/bin_tree.png
|
|
19
19
|
images/bin_tree.py
|
|
20
|
+
images/bin_tree2.py
|
|
21
|
+
images/bin_tree2.py~
|
|
20
22
|
images/copies.png
|
|
21
23
|
images/copies.py
|
|
22
24
|
images/copy_method.png
|
|
@@ -58,8 +60,8 @@ images/linked_list.png
|
|
|
58
60
|
images/linked_list.py
|
|
59
61
|
images/many_types.png
|
|
60
62
|
images/many_types.py
|
|
61
|
-
images/memory_graph.gv
|
|
62
63
|
images/memory_graph.gv.pdf
|
|
64
|
+
images/memory_graph.pdf
|
|
63
65
|
images/mutable.py
|
|
64
66
|
images/mutable1.png
|
|
65
67
|
images/mutable2.png
|
|
@@ -11,7 +11,7 @@ long_description_from_readme = (this_directory / "README.md").read_text()
|
|
|
11
11
|
|
|
12
12
|
setup(
|
|
13
13
|
name = 'memory_graph',
|
|
14
|
-
version = '0.3.
|
|
14
|
+
version = '0.3.17',
|
|
15
15
|
description = 'Generate intuitive graphs of your Python data, great for debugging and understanding complex relationships.',
|
|
16
16
|
long_description = long_description_from_readme,
|
|
17
17
|
long_description_content_type = 'text/markdown',
|
|
Binary file
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# This file is part of memory_graph.
|
|
2
|
-
# Copyright (c) 2023, Bas Terwijn.
|
|
3
|
-
# SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
-
|
|
5
|
-
import memory_graph as mg
|
|
6
|
-
import random
|
|
7
|
-
random.seed(0) # use same random numbers each run
|
|
8
|
-
|
|
9
|
-
class Node:
|
|
10
|
-
|
|
11
|
-
def __init__(self, value):
|
|
12
|
-
self.smaller = None
|
|
13
|
-
self.value = value
|
|
14
|
-
self.larger = None
|
|
15
|
-
|
|
16
|
-
class BinTree:
|
|
17
|
-
|
|
18
|
-
def __init__(self):
|
|
19
|
-
self.root = None
|
|
20
|
-
|
|
21
|
-
def add_recursive(self, new_value, node):
|
|
22
|
-
if new_value < node.value:
|
|
23
|
-
if node.smaller is None:
|
|
24
|
-
node.smaller = Node(new_value)
|
|
25
|
-
else:
|
|
26
|
-
self.add_recursive(new_value, node.smaller)
|
|
27
|
-
else:
|
|
28
|
-
if node.larger is None:
|
|
29
|
-
node.larger = Node(new_value)
|
|
30
|
-
else:
|
|
31
|
-
self.add_recursive(new_value, node.larger)
|
|
32
|
-
if new_value == 51:
|
|
33
|
-
mg.render(locals(), f"bin_tree.png")
|
|
34
|
-
exit(0)
|
|
35
|
-
|
|
36
|
-
def add(self, value):
|
|
37
|
-
if self.root is None:
|
|
38
|
-
self.root = Node(value)
|
|
39
|
-
else:
|
|
40
|
-
self.add_recursive(value, self.root)
|
|
41
|
-
|
|
42
|
-
tree = BinTree()
|
|
43
|
-
n = 100
|
|
44
|
-
for i in range(n):
|
|
45
|
-
new_value = random.randrange(n)
|
|
46
|
-
tree.add(new_value)
|
|
47
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
digraph memory_graph {
|
|
2
|
-
node [shape=plaintext]
|
|
3
|
-
node126810958314944 [label=<
|
|
4
|
-
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="0" BGCOLOR="lightcoral"><TR><TD PORT="table">
|
|
5
|
-
<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="5" CELLPADDING="0">
|
|
6
|
-
<TR><TD><font color="#505050">0</font></TD><TD BORDER="1"> 0 </TD></TR>
|
|
7
|
-
<TR><TD><font color="#505050">1</font></TD><TD BORDER="1"> 1 </TD></TR>
|
|
8
|
-
</TABLE>
|
|
9
|
-
</TD></TR></TABLE>
|
|
10
|
-
> xlabel=list]
|
|
11
|
-
node126810936962048 [label=<
|
|
12
|
-
<TABLE BORDER="0" CELLBORDER="3" CELLSPACING="0" CELLPADDING="0" BGCOLOR="dodgerblue1"><TR><TD PORT="table">
|
|
13
|
-
<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="5" CELLPADDING="0">
|
|
14
|
-
<TR><TD BORDER="1" STYLE="ROUNDED"> data </TD><TD BORDER="1" STYLE="ROUNDED"> i </TD></TR>
|
|
15
|
-
<TR><TD BORDER="1" PORT="ref0"> </TD><TD BORDER="1"> 1 </TD></TR>
|
|
16
|
-
</TABLE>
|
|
17
|
-
</TD></TR></TABLE>
|
|
18
|
-
> xlabel=dict]
|
|
19
|
-
node126810936962048:ref0 -> node126810958314944:table [style=solid]
|
|
20
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|