89729dc16db02d4ec275783113653a484b22bb77..a95dc36edf331905b871820ddff4f8e8c0b38209
2024-09-09 Hong-Phuc Bui
set function plot thinner
a95dc3 diff | tree
2024-08-25 Hong-Phuc Bui
example about graph
273021 diff | tree
6 files modified
2 files added
95 ■■■■ changed files
.gitignore 3 ●●●●● patch | view | raw | blame | history
num-int/Readme.md 2 ●●● patch | view | raw | blame | history
num-int/num-int.pyproject 2 ●●● patch | view | raw | blame | history
num-int/src/numint/expression.py 2 ●●● patch | view | raw | blame | history
num-int/src/numint/mainwindow.ui 2 ●●● patch | view | raw | blame | history
stundenplan/src/pygraph/graphdemo.py 30 ●●●● patch | view | raw | blame | history
stundenplan/src/pygraph/shortestpath.py 28 ●●●●● patch | view | raw | blame | history
stundenplan/tests/pygraph/shortestpath_tests.py 26 ●●●●● patch | view | raw | blame | history
.gitignore
@@ -1,7 +1,4 @@
sandbox*
queens*
*.venv*
__pycache__/
.idea/
htw-python-kurs-2024-mmb/
*.egg-info/
num-int/Readme.md
@@ -7,7 +7,7 @@
# build the ui
pyside6-project build num-int.pyproject
# build the grammar
python -m lark.tools.standalone json.lark > json_parser.py
python -m lark.tools.standalone expression.lark > expression.py
```
## Run Unittest
num-int/num-int.pyproject
@@ -3,6 +3,6 @@
        "src/numint/__init__.py",
        "src/numint/main.py",
        "src/numint/mainwindow.ui",
        "src/numint/RiemannSum.py"
        "src/numint/riemann_sum.py"
    ]
}
num-int/src/numint/expression.py
@@ -3427,7 +3427,7 @@
import pickle, zlib, base64
DATA = (
{'parser': {'lexer_conf': {'terminals': [{'@': 0}, {'@': 1}, {'@': 2}, {'@': 3}, {'@': 4}, {'@': 5}, {'@': 6}, {'@': 7}, {'@': 8}, {'@': 9}, {'@': 10}], 'ignore': ['WS_INLINE'], 'g_regex_flags': 0, 'use_bytes': False, 'lexer_type': 'contextual', '__type__': 'LexerConf'}, 'parser_conf': {'rules': [{'@': 11}, {'@': 12}, {'@': 13}, {'@': 14}, {'@': 15}, {'@': 16}, {'@': 17}, {'@': 18}, {'@': 19}, {'@': 20}, {'@': 21}, {'@': 22}, {'@': 23}, {'@': 24}, {'@': 25}, {'@': 26}, {'@': 27}, {'@': 28}, {'@': 29}], 'start': ['start'], 'parser_type': 'lalr', '__type__': 'ParserConf'}, 'parser': {'tokens': {0: 'LPAR', 1: 'COMMA', 2: 'SLASH', 3: 'RPAR', 4: '__ANON_0', 5: 'STAR', 6: 'PLUS', 7: 'MINUS', 8: '$END', 9: 'NAME', 10: 'exponent', 11: 'sum', 12: 'product', 13: 'atom', 14: 'NUMBER', 15: 'argv', 16: 'start', 17: '__argv_star_0'}, 'states': {0: {0: (0, 16), 1: (1, {'@': 22}), 2: (1, {'@': 22}), 3: (1, {'@': 22}), 4: (1, {'@': 22}), 5: (1, {'@': 22}), 6: (1, {'@': 22}), 7: (1, {'@': 22}), 8: (1, {'@': 22})}, 1: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 31), 11: (0, 10), 12: (0, 7), 13: (0, 12), 14: (0, 4)}, 2: {}, 3: {7: (0, 30), 6: (0, 5), 3: (1, {'@': 28}), 1: (1, {'@': 28})}, 4: {1: (1, {'@': 20}), 2: (1, {'@': 20}), 3: (1, {'@': 20}), 4: (1, {'@': 20}), 5: (1, {'@': 20}), 6: (1, {'@': 20}), 7: (1, {'@': 20}), 8: (1, {'@': 20})}, 5: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 31), 12: (0, 15), 13: (0, 12), 14: (0, 4)}, 6: {1: (1, {'@': 19}), 2: (1, {'@': 19}), 3: (1, {'@': 19}), 5: (1, {'@': 19}), 6: (1, {'@': 19}), 7: (1, {'@': 19}), 8: (1, {'@': 19})}, 7: {5: (0, 28), 2: (0, 18), 1: (1, {'@': 12}), 6: (1, {'@': 12}), 3: (1, {'@': 12}), 7: (1, {'@': 12}), 8: (1, {'@': 12})}, 8: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 31), 11: (0, 13), 12: (0, 7), 13: (0, 12), 14: (0, 4)}, 9: {5: (0, 28), 2: (0, 18), 1: (1, {'@': 14}), 6: (1, {'@': 14}), 3: (1, {'@': 14}), 7: (1, {'@': 14}), 8: (1, {'@': 14})}, 10: {7: (0, 30), 6: (0, 5), 3: (1, {'@': 29}), 1: (1, {'@': 29})}, 11: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 31), 11: (0, 3), 12: (0, 7), 13: (0, 12), 14: (0, 4)}, 12: {4: (0, 23), 1: (1, {'@': 18}), 2: (1, {'@': 18}), 3: (1, {'@': 18}), 5: (1, {'@': 18}), 6: (1, {'@': 18}), 7: (1, {'@': 18}), 8: (1, {'@': 18})}, 13: {7: (0, 30), 3: (0, 22), 6: (0, 5)}, 14: {3: (0, 29)}, 15: {5: (0, 28), 2: (0, 18), 1: (1, {'@': 13}), 6: (1, {'@': 13}), 3: (1, {'@': 13}), 7: (1, {'@': 13}), 8: (1, {'@': 13})}, 16: {10: (0, 31), 15: (0, 14), 12: (0, 7), 11: (0, 24), 7: (0, 19), 0: (0, 8), 9: (0, 0), 13: (0, 12), 14: (0, 4), 3: (1, {'@': 27})}, 17: {7: (0, 30), 6: (0, 5), 8: (1, {'@': 11})}, 18: {7: (0, 19), 0: (0, 8), 9: (0, 0), 13: (0, 12), 14: (0, 4), 10: (0, 21)}, 19: {7: (0, 19), 0: (0, 8), 9: (0, 0), 14: (0, 4), 13: (0, 26)}, 20: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 31), 11: (0, 17), 12: (0, 7), 16: (0, 2), 13: (0, 12), 14: (0, 4)}, 21: {1: (1, {'@': 17}), 2: (1, {'@': 17}), 3: (1, {'@': 17}), 5: (1, {'@': 17}), 6: (1, {'@': 17}), 7: (1, {'@': 17}), 8: (1, {'@': 17})}, 22: {1: (1, {'@': 23}), 2: (1, {'@': 23}), 3: (1, {'@': 23}), 4: (1, {'@': 23}), 5: (1, {'@': 23}), 6: (1, {'@': 23}), 7: (1, {'@': 23}), 8: (1, {'@': 23})}, 23: {7: (0, 19), 0: (0, 8), 9: (0, 0), 10: (0, 6), 13: (0, 12), 14: (0, 4)}, 24: {17: (0, 27), 1: (0, 11), 7: (0, 30), 6: (0, 5), 3: (1, {'@': 26})}, 25: {1: (1, {'@': 16}), 2: (1, {'@': 16}), 3: (1, {'@': 16}), 5: (1, {'@': 16}), 6: (1, {'@': 16}), 7: (1, {'@': 16}), 8: (1, {'@': 16})}, 26: {1: (1, {'@': 21}), 2: (1, {'@': 21}), 3: (1, {'@': 21}), 4: (1, {'@': 21}), 5: (1, {'@': 21}), 6: (1, {'@': 21}), 7: (1, {'@': 21}), 8: (1, {'@': 21})}, 27: {1: (0, 1), 3: (1, {'@': 25})}, 28: {7: (0, 19), 0: (0, 8), 9: (0, 0), 13: (0, 12), 14: (0, 4), 10: (0, 25)}, 29: {1: (1, {'@': 24}), 2: (1, {'@': 24}), 3: (1, {'@': 24}), 4: (1, {'@': 24}), 5: (1, {'@': 24}), 6: (1, {'@': 24}), 7: (1, {'@': 24}), 8: (1, {'@': 24})}, 30: {7: (0, 19), 0: (0, 8), 9: (0, 0), 12: (0, 9), 10: (0, 31), 13: (0, 12), 14: (0, 4)}, 31: {1: (1, {'@': 15}), 2: (1, {'@': 15}), 3: (1, {'@': 15}), 5: (1, {'@': 15}), 6: (1, {'@': 15}), 7: (1, {'@': 15}), 8: (1, {'@': 15})}}, 'start_states': {'start': 20}, 'end_states': {'start': 2}}, '__type__': 'ParsingFrontend'}, 'rules': [{'@': 11}, {'@': 12}, {'@': 13}, {'@': 14}, {'@': 15}, {'@': 16}, {'@': 17}, {'@': 18}, {'@': 19}, {'@': 20}, {'@': 21}, {'@': 22}, {'@': 23}, {'@': 24}, {'@': 25}, {'@': 26}, {'@': 27}, {'@': 28}, {'@': 29}], 'options': {'debug': False, 'strict': False, 'keep_all_tokens': False, 'tree_class': None, 'cache': False, 'postlex': None, 'parser': 'lalr', 'lexer': 'contextual', 'transformer': None, 'start': ['start'], 'priority': 'normal', 'ambiguity': 'auto', 'regex': False, 'propagate_positions': False, 'lexer_callbacks': {}, 'maybe_placeholders': False, 'edit_terminals': None, 'g_regex_flags': 0, 'use_bytes': False, 'ordered_sets': True, 'import_paths': [], 'source_path': None, '_plugins': {}}, '__type__': 'Lark'}
{'parser': {'lexer_conf': {'terminals': [{'@': 0}, {'@': 1}, {'@': 2}, {'@': 3}, {'@': 4}, {'@': 5}, {'@': 6}, {'@': 7}, {'@': 8}, {'@': 9}, {'@': 10}], 'ignore': ['WS_INLINE'], 'g_regex_flags': 0, 'use_bytes': False, 'lexer_type': 'contextual', '__type__': 'LexerConf'}, 'parser_conf': {'rules': [{'@': 11}, {'@': 12}, {'@': 13}, {'@': 14}, {'@': 15}, {'@': 16}, {'@': 17}, {'@': 18}, {'@': 19}, {'@': 20}, {'@': 21}, {'@': 22}, {'@': 23}, {'@': 24}, {'@': 25}, {'@': 26}, {'@': 27}, {'@': 28}, {'@': 29}], 'start': ['start'], 'parser_type': 'lalr', '__type__': 'ParserConf'}, 'parser': {'tokens': {0: 'atom', 1: 'NAME', 2: 'product', 3: 'LPAR', 4: 'exponent', 5: 'NUMBER', 6: 'MINUS', 7: 'PLUS', 8: '$END', 9: 'COMMA', 10: 'RPAR', 11: 'STAR', 12: 'SLASH', 13: '__ANON_0', 14: 'sum', 15: '__argv_star_0', 16: 'start', 17: 'argv'}, 'states': {0: {0: (0, 28), 1: (0, 27), 2: (0, 11), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 1: {0: (0, 28), 1: (0, 27), 4: (0, 18), 3: (0, 8), 5: (0, 4), 6: (0, 5)}, 2: {6: (0, 16), 7: (0, 0), 8: (1, {'@': 11})}, 3: {6: (0, 16), 7: (0, 0), 9: (1, {'@': 28}), 10: (1, {'@': 28})}, 4: {11: (1, {'@': 20}), 12: (1, {'@': 20}), 8: (1, {'@': 20}), 7: (1, {'@': 20}), 9: (1, {'@': 20}), 10: (1, {'@': 20}), 6: (1, {'@': 20}), 13: (1, {'@': 20})}, 5: {0: (0, 7), 3: (0, 8), 1: (0, 27), 5: (0, 4), 6: (0, 5)}, 6: {10: (0, 9), 6: (0, 16), 7: (0, 0)}, 7: {11: (1, {'@': 21}), 12: (1, {'@': 21}), 8: (1, {'@': 21}), 7: (1, {'@': 21}), 9: (1, {'@': 21}), 10: (1, {'@': 21}), 6: (1, {'@': 21}), 13: (1, {'@': 21})}, 8: {0: (0, 28), 14: (0, 6), 1: (0, 27), 2: (0, 10), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 9: {11: (1, {'@': 23}), 12: (1, {'@': 23}), 8: (1, {'@': 23}), 7: (1, {'@': 23}), 9: (1, {'@': 23}), 10: (1, {'@': 23}), 6: (1, {'@': 23}), 13: (1, {'@': 23})}, 10: {11: (0, 19), 12: (0, 1), 7: (1, {'@': 12}), 6: (1, {'@': 12}), 10: (1, {'@': 12}), 9: (1, {'@': 12}), 8: (1, {'@': 12})}, 11: {11: (0, 19), 12: (0, 1), 7: (1, {'@': 13}), 6: (1, {'@': 13}), 10: (1, {'@': 13}), 9: (1, {'@': 13}), 8: (1, {'@': 13})}, 12: {11: (1, {'@': 24}), 12: (1, {'@': 24}), 8: (1, {'@': 24}), 7: (1, {'@': 24}), 9: (1, {'@': 24}), 10: (1, {'@': 24}), 6: (1, {'@': 24}), 13: (1, {'@': 24})}, 13: {10: (0, 12)}, 14: {0: (0, 28), 14: (0, 31), 1: (0, 27), 2: (0, 10), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 15: {15: (0, 20), 9: (0, 21), 6: (0, 16), 7: (0, 0), 10: (1, {'@': 26})}, 16: {0: (0, 28), 1: (0, 27), 2: (0, 22), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 17: {11: (1, {'@': 15}), 12: (1, {'@': 15}), 8: (1, {'@': 15}), 7: (1, {'@': 15}), 9: (1, {'@': 15}), 10: (1, {'@': 15}), 6: (1, {'@': 15})}, 18: {11: (1, {'@': 17}), 12: (1, {'@': 17}), 8: (1, {'@': 17}), 7: (1, {'@': 17}), 9: (1, {'@': 17}), 10: (1, {'@': 17}), 6: (1, {'@': 17})}, 19: {0: (0, 28), 4: (0, 25), 1: (0, 27), 3: (0, 8), 5: (0, 4), 6: (0, 5)}, 20: {9: (0, 14), 10: (1, {'@': 25})}, 21: {0: (0, 28), 14: (0, 3), 1: (0, 27), 2: (0, 10), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 22: {11: (0, 19), 12: (0, 1), 7: (1, {'@': 14}), 6: (1, {'@': 14}), 10: (1, {'@': 14}), 9: (1, {'@': 14}), 8: (1, {'@': 14})}, 23: {0: (0, 28), 1: (0, 27), 4: (0, 29), 3: (0, 8), 5: (0, 4), 6: (0, 5)}, 24: {0: (0, 28), 16: (0, 30), 14: (0, 2), 1: (0, 27), 2: (0, 10), 3: (0, 8), 4: (0, 17), 5: (0, 4), 6: (0, 5)}, 25: {11: (1, {'@': 16}), 12: (1, {'@': 16}), 8: (1, {'@': 16}), 7: (1, {'@': 16}), 9: (1, {'@': 16}), 10: (1, {'@': 16}), 6: (1, {'@': 16})}, 26: {17: (0, 13), 14: (0, 15), 1: (0, 27), 2: (0, 10), 3: (0, 8), 6: (0, 5), 0: (0, 28), 4: (0, 17), 5: (0, 4), 10: (1, {'@': 27})}, 27: {3: (0, 26), 11: (1, {'@': 22}), 12: (1, {'@': 22}), 8: (1, {'@': 22}), 7: (1, {'@': 22}), 9: (1, {'@': 22}), 10: (1, {'@': 22}), 6: (1, {'@': 22}), 13: (1, {'@': 22})}, 28: {13: (0, 23), 11: (1, {'@': 18}), 12: (1, {'@': 18}), 6: (1, {'@': 18}), 8: (1, {'@': 18}), 7: (1, {'@': 18}), 9: (1, {'@': 18}), 10: (1, {'@': 18})}, 29: {11: (1, {'@': 19}), 12: (1, {'@': 19}), 6: (1, {'@': 19}), 8: (1, {'@': 19}), 7: (1, {'@': 19}), 9: (1, {'@': 19}), 10: (1, {'@': 19})}, 30: {}, 31: {6: (0, 16), 7: (0, 0), 9: (1, {'@': 29}), 10: (1, {'@': 29})}}, 'start_states': {'start': 24}, 'end_states': {'start': 30}}, '__type__': 'ParsingFrontend'}, 'rules': [{'@': 11}, {'@': 12}, {'@': 13}, {'@': 14}, {'@': 15}, {'@': 16}, {'@': 17}, {'@': 18}, {'@': 19}, {'@': 20}, {'@': 21}, {'@': 22}, {'@': 23}, {'@': 24}, {'@': 25}, {'@': 26}, {'@': 27}, {'@': 28}, {'@': 29}], 'options': {'debug': False, 'strict': False, 'keep_all_tokens': False, 'tree_class': None, 'cache': False, 'postlex': None, 'parser': 'lalr', 'lexer': 'contextual', 'transformer': None, 'start': ['start'], 'priority': 'normal', 'ambiguity': 'auto', 'regex': False, 'propagate_positions': False, 'lexer_callbacks': {}, 'maybe_placeholders': False, 'edit_terminals': None, 'g_regex_flags': 0, 'use_bytes': False, 'ordered_sets': True, 'import_paths': [], 'source_path': None, '_plugins': {}}, '__type__': 'Lark'}
)
MEMO = (
{0: {'name': 'NUMBER', 'pattern': {'value': '(?:(?:(?:[0-9])+(?:e|E)(?:(?:\\+|\\-))?(?:[0-9])+|(?:(?:[0-9])+\\.(?:(?:[0-9])+)?|\\.(?:[0-9])+)(?:(?:e|E)(?:(?:\\+|\\-))?(?:[0-9])+)?)|(?:[0-9])+)', 'flags': [], 'raw': None, '_width': [1, 18446744073709551616], '__type__': 'PatternRE'}, 'priority': 0, '__type__': 'TerminalDef'}, 1: {'name': 'NAME', 'pattern': {'value': '(?:(?:[A-Z]|[a-z])|_)(?:(?:(?:[A-Z]|[a-z])|[0-9]|_))*', 'flags': [], 'raw': None, '_width': [1, 18446744073709551616], '__type__': 'PatternRE'}, 'priority': 0, '__type__': 'TerminalDef'}, 2: {'name': 'WS_INLINE', 'pattern': {'value': '(?:(?:\\ |\t))+', 'flags': [], 'raw': None, '_width': [1, 18446744073709551616], '__type__': 'PatternRE'}, 'priority': 0, '__type__': 'TerminalDef'}, 3: {'name': 'PLUS', 'pattern': {'value': '+', 'flags': [], 'raw': '"+"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 4: {'name': 'MINUS', 'pattern': {'value': '-', 'flags': [], 'raw': '"-"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 5: {'name': 'STAR', 'pattern': {'value': '*', 'flags': [], 'raw': '"*"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 6: {'name': 'SLASH', 'pattern': {'value': '/', 'flags': [], 'raw': '"/"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 7: {'name': '__ANON_0', 'pattern': {'value': '**', 'flags': [], 'raw': '"**"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 8: {'name': 'LPAR', 'pattern': {'value': '(', 'flags': [], 'raw': '"("', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 9: {'name': 'RPAR', 'pattern': {'value': ')', 'flags': [], 'raw': '")"', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 10: {'name': 'COMMA', 'pattern': {'value': ',', 'flags': [], 'raw': '","', '__type__': 'PatternStr'}, 'priority': 0, '__type__': 'TerminalDef'}, 11: {'origin': {'name': Token('RULE', 'start'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'sum', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 12: {'origin': {'name': Token('RULE', 'sum'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'product', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 13: {'origin': {'name': Token('RULE', 'sum'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'sum', '__type__': 'NonTerminal'}, {'name': 'PLUS', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'product', '__type__': 'NonTerminal'}], 'order': 1, 'alias': 'add', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 14: {'origin': {'name': Token('RULE', 'sum'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'sum', '__type__': 'NonTerminal'}, {'name': 'MINUS', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'product', '__type__': 'NonTerminal'}], 'order': 2, 'alias': 'sub', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 15: {'origin': {'name': Token('RULE', 'product'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'exponent', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 16: {'origin': {'name': Token('RULE', 'product'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'product', '__type__': 'NonTerminal'}, {'name': 'STAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'exponent', '__type__': 'NonTerminal'}], 'order': 1, 'alias': 'mul', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 17: {'origin': {'name': Token('RULE', 'product'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'product', '__type__': 'NonTerminal'}, {'name': 'SLASH', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'exponent', '__type__': 'NonTerminal'}], 'order': 2, 'alias': 'div', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 18: {'origin': {'name': Token('RULE', 'exponent'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'atom', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 19: {'origin': {'name': Token('RULE', 'exponent'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'atom', '__type__': 'NonTerminal'}, {'name': '__ANON_0', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'exponent', '__type__': 'NonTerminal'}], 'order': 1, 'alias': 'exponent', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 20: {'origin': {'name': Token('RULE', 'atom'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'NUMBER', 'filter_out': False, '__type__': 'Terminal'}], 'order': 0, 'alias': 'number', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 21: {'origin': {'name': Token('RULE', 'atom'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'MINUS', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'atom', '__type__': 'NonTerminal'}], 'order': 1, 'alias': 'neg', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 22: {'origin': {'name': Token('RULE', 'atom'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'NAME', 'filter_out': False, '__type__': 'Terminal'}], 'order': 2, 'alias': 'var', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 23: {'origin': {'name': Token('RULE', 'atom'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LPAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'sum', '__type__': 'NonTerminal'}, {'name': 'RPAR', 'filter_out': True, '__type__': 'Terminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 24: {'origin': {'name': Token('RULE', 'atom'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'NAME', 'filter_out': False, '__type__': 'Terminal'}, {'name': 'LPAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'argv', '__type__': 'NonTerminal'}, {'name': 'RPAR', 'filter_out': True, '__type__': 'Terminal'}], 'order': 4, 'alias': 'function', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 25: {'origin': {'name': Token('RULE', 'argv'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'sum', '__type__': 'NonTerminal'}, {'name': '__argv_star_0', '__type__': 'NonTerminal'}], 'order': 0, 'alias': 'argv', 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 26: {'origin': {'name': Token('RULE', 'argv'), '__type__': 'NonTerminal'}, 'expansion': [{'name': 'sum', '__type__': 'NonTerminal'}], 'order': 1, 'alias': 'argv', 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 27: {'origin': {'name': Token('RULE', 'argv'), '__type__': 'NonTerminal'}, 'expansion': [], 'order': 2, 'alias': 'argv', 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (True,), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 28: {'origin': {'name': '__argv_star_0', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'sum', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 29: {'origin': {'name': '__argv_star_0', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__argv_star_0', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'sum', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}}
num-int/src/numint/mainwindow.ui
@@ -11,7 +11,7 @@
   </rect>
  </property>
  <property name="windowTitle">
   <string>Riemann Sum</string>
   <string>Riemann Sums</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QHBoxLayout" name="horizontalLayout_2">
stundenplan/src/pygraph/graphdemo.py
@@ -6,7 +6,7 @@
        self._adjacent: dict[int, set] = {}
        self._vertex_attribute: dict[int, dict] = {}
    def add_vertex(self, vertex):
    def add_vertex(self, vertex:int):
        if vertex not in self._adjacent:
            if not isinstance(vertex, int):
                raise TypeError(f"Argument {vertex} is not a valid vertex")
@@ -14,7 +14,7 @@
            self._vertex_attribute[vertex] = {}
        pass
    def add_edge(self, u, v):
    def add_edge(self, u: int, v: int):
        self.add_vertex(u)
        self.add_vertex(v)
        v_neighbor = self._adjacent[v]
@@ -25,6 +25,11 @@
            u_neighbor.add(v)
        pass
    def add_edges(self, u: int, adjacent:[int]):
        for v in adjacent:
            self.add_edge(u, v)
        pass
    def merge_attribute(self, vertex: int, properties: dict):
        """
        merge a dict of attribute to a vertex. Usage example:
@@ -39,7 +44,7 @@
        """
        if vertex not in self._adjacent:
            raise ValueError(f"Graph does not include vertex {vertex}")
        old_attributes = self._vertex_attribute.get[vertex]
        old_attributes = self._vertex_attribute.get(vertex)
        self._vertex_attribute[vertex] = old_attributes | properties
        return self
        pass
@@ -52,20 +57,33 @@
        pass
    def vertices(self):
        """
        returns the set of vertices in not defined order.
        :return:
        """
        return self._adjacent.keys()
    def for_each_vertices(self, action: Callable[[int], Any]):
        for v in self.vertices():
        """
        iterates over all vertices in this graph in ascending order.
        :param action:
        :return:
        """
        for v in sorted( self.vertices() ):
            action(v)
    def adjacent_of(self, vertex: int):
        if vertex not in self._adjacent:
            raise ValueError(f"Graph does not include vertex {vertex}")
        return self._adjacent.get(vertex)
        return sorted( self._adjacent.get(vertex) )
    def for_each_edges(self, action: Callable[[int, int], Any]):
        """
        iterates over all edges of the graph, executes the action on each edge.
        :param action: a binary function, its parameters are start and end vertices of the visited edges
        """
        visited_edges: dict[int, set] = {}
        for start in self.vertices():
        for start in sorted( self.vertices() ):
            for end in self.adjacent_of(start):
                (first, second) = (start, end) if (start >= end) else (end, start)
            if first in visited_edges:
stundenplan/src/pygraph/shortestpath.py
New file
@@ -0,0 +1,28 @@
import collections
from pygraph.graphdemo import Graph
def bfs(g: Graph, start: int) -> {int:int|None}:
    """
    :param g:
    :param start:
    :return:
    """
    tree = Graph()
    queue = collections.deque()
    VISITED = "visited"
    not_visited = {VISITED: False}
    visited = {VISITED: True}
    g.for_each_vertices(lambda v : g.merge_attribute(v, not_visited))
    queue.append(start)  # append() is the enqueue() operation of a Queue
    g.merge_attribute(start, visited)
    while queue:
        u = queue.popleft()  # popleft() is the dequeue() operation of a Queue
        for v in g.adjacent_of(u):
            if not g.get_attribute(v)[VISITED]:
                tree.add_edge(u, v)
                g.merge_attribute(v, visited)
                queue.append(v)
    return tree
stundenplan/tests/pygraph/shortestpath_tests.py
New file
@@ -0,0 +1,26 @@
import unittest
from pygraph.graphdemo import Graph
from pygraph.shortestpath import bfs
class ShortestPathTestCase(unittest.TestCase):
    def test_bfs(self):
        g = Graph()
        g.add_edges(0, [1, 2])
        g.add_edges(1, [0, 3, 4])
        g.add_edges(2, [0, 4, 6, 7])
        g.add_edges(3, [1])
        g.add_edges(4, [1, 2, 5])
        g.add_edges(5, [4])
        g.add_edges(6, [2])
        g.add_edges(7, [2])
        #print(g)
        # self.assertEqual(True, False)  # add assertion here
        tree = bfs(g, 0)
        print(tree)
if __name__ == '__main__':
    unittest.main()