digraphx 0.1__tar.gz → 0.3__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.
Files changed (205) hide show
  1. {digraphx-0.1 → digraphx-0.3}/.github/workflows/multi-platforms.yml +6 -5
  2. {digraphx-0.1 → digraphx-0.3}/.pre-commit-config.yaml +2 -0
  3. digraphx-0.3/.vscode/settings.json +3 -0
  4. digraphx-0.3/AGENTS.md +127 -0
  5. {digraphx-0.1 → digraphx-0.3}/CONTRIBUTING.md +2 -86
  6. digraphx-0.3/GEMINI.md +65 -0
  7. digraphx-0.3/IFLOW.md +103 -0
  8. {digraphx-0.1 → digraphx-0.3}/LICENSE.txt +1 -1
  9. digraphx-0.3/PKG-INFO +230 -0
  10. digraphx-0.3/README.md +207 -0
  11. digraphx-0.3/coverage.json +1 -0
  12. digraphx-0.3/cpp_ai/.gitignore +152 -0
  13. digraphx-0.3/cpp_ai/CMakeLists.txt +110 -0
  14. digraphx-0.3/cpp_ai/README.md +185 -0
  15. digraphx-0.3/cpp_ai/examples/basic_usage.cpp +126 -0
  16. digraphx-0.3/cpp_ai/include/cppcoro/async_auto_reset_event.hpp +89 -0
  17. digraphx-0.3/cpp_ai/include/cppcoro/async_generator.hpp +856 -0
  18. digraphx-0.3/cpp_ai/include/cppcoro/async_latch.hpp +62 -0
  19. digraphx-0.3/cpp_ai/include/cppcoro/async_manual_reset_event.hpp +95 -0
  20. digraphx-0.3/cpp_ai/include/cppcoro/async_mutex.hpp +174 -0
  21. digraphx-0.3/cpp_ai/include/cppcoro/async_scope.hpp +81 -0
  22. digraphx-0.3/cpp_ai/include/cppcoro/awaitable_traits.hpp +22 -0
  23. digraphx-0.3/cpp_ai/include/cppcoro/broken_promise.hpp +20 -0
  24. digraphx-0.3/cpp_ai/include/cppcoro/cancellation_registration.hpp +80 -0
  25. digraphx-0.3/cpp_ai/include/cppcoro/cancellation_source.hpp +65 -0
  26. digraphx-0.3/cpp_ai/include/cppcoro/cancellation_token.hpp +63 -0
  27. digraphx-0.3/cpp_ai/include/cppcoro/config.hpp +177 -0
  28. digraphx-0.3/cpp_ai/include/cppcoro/coroutine.hpp +35 -0
  29. digraphx-0.3/cpp_ai/include/cppcoro/detail/any.hpp +17 -0
  30. digraphx-0.3/cpp_ai/include/cppcoro/detail/get_awaiter.hpp +40 -0
  31. digraphx-0.3/cpp_ai/include/cppcoro/detail/is_awaiter.hpp +43 -0
  32. digraphx-0.3/cpp_ai/include/cppcoro/detail/lightweight_manual_reset_event.hpp +56 -0
  33. digraphx-0.3/cpp_ai/include/cppcoro/detail/manual_lifetime.hpp +101 -0
  34. digraphx-0.3/cpp_ai/include/cppcoro/detail/remove_rvalue_reference.hpp +19 -0
  35. digraphx-0.3/cpp_ai/include/cppcoro/detail/sync_wait_task.hpp +226 -0
  36. digraphx-0.3/cpp_ai/include/cppcoro/detail/unwrap_reference.hpp +22 -0
  37. digraphx-0.3/cpp_ai/include/cppcoro/detail/void_value.hpp +14 -0
  38. digraphx-0.3/cpp_ai/include/cppcoro/detail/when_all_counter.hpp +43 -0
  39. digraphx-0.3/cpp_ai/include/cppcoro/detail/when_all_ready_awaitable.hpp +170 -0
  40. digraphx-0.3/cpp_ai/include/cppcoro/detail/when_all_task.hpp +257 -0
  41. digraphx-0.3/cpp_ai/include/cppcoro/detail/win32.hpp +136 -0
  42. digraphx-0.3/cpp_ai/include/cppcoro/detail/win32_overlapped_operation.hpp +295 -0
  43. digraphx-0.3/cpp_ai/include/cppcoro/file.hpp +46 -0
  44. digraphx-0.3/cpp_ai/include/cppcoro/file_buffering_mode.hpp +27 -0
  45. digraphx-0.3/cpp_ai/include/cppcoro/file_open_mode.hpp +38 -0
  46. digraphx-0.3/cpp_ai/include/cppcoro/file_read_operation.hpp +75 -0
  47. digraphx-0.3/cpp_ai/include/cppcoro/file_share_mode.hpp +39 -0
  48. digraphx-0.3/cpp_ai/include/cppcoro/file_write_operation.hpp +74 -0
  49. digraphx-0.3/cpp_ai/include/cppcoro/filesystem.hpp +24 -0
  50. digraphx-0.3/cpp_ai/include/cppcoro/fmap.hpp +131 -0
  51. digraphx-0.3/cpp_ai/include/cppcoro/generator.hpp +187 -0
  52. digraphx-0.3/cpp_ai/include/cppcoro/inline_scheduler.hpp +19 -0
  53. digraphx-0.3/cpp_ai/include/cppcoro/io_service.hpp +277 -0
  54. digraphx-0.3/cpp_ai/include/cppcoro/is_awaitable.hpp +21 -0
  55. digraphx-0.3/cpp_ai/include/cppcoro/multi_producer_sequencer.hpp +721 -0
  56. digraphx-0.3/cpp_ai/include/cppcoro/net/ip_address.hpp +112 -0
  57. digraphx-0.3/cpp_ai/include/cppcoro/net/ip_endpoint.hpp +122 -0
  58. digraphx-0.3/cpp_ai/include/cppcoro/net/ipv4_address.hpp +91 -0
  59. digraphx-0.3/cpp_ai/include/cppcoro/net/ipv4_endpoint.hpp +54 -0
  60. digraphx-0.3/cpp_ai/include/cppcoro/net/ipv6_address.hpp +185 -0
  61. digraphx-0.3/cpp_ai/include/cppcoro/net/ipv6_endpoint.hpp +54 -0
  62. digraphx-0.3/cpp_ai/include/cppcoro/net/socket.hpp +241 -0
  63. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_accept_operation.hpp +86 -0
  64. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_connect_operation.hpp +75 -0
  65. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_disconnect_operation.hpp +70 -0
  66. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_recv_from_operation.hpp +83 -0
  67. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_recv_operation.hpp +70 -0
  68. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_send_operation.hpp +70 -0
  69. digraphx-0.3/cpp_ai/include/cppcoro/net/socket_send_to_operation.hpp +77 -0
  70. digraphx-0.3/cpp_ai/include/cppcoro/on_scope_exit.hpp +111 -0
  71. digraphx-0.3/cpp_ai/include/cppcoro/operation_cancelled.hpp +19 -0
  72. digraphx-0.3/cpp_ai/include/cppcoro/read_only_file.hpp +53 -0
  73. digraphx-0.3/cpp_ai/include/cppcoro/read_write_file.hpp +61 -0
  74. digraphx-0.3/cpp_ai/include/cppcoro/readable_file.hpp +54 -0
  75. digraphx-0.3/cpp_ai/include/cppcoro/recursive_generator.hpp +254 -0
  76. digraphx-0.3/cpp_ai/include/cppcoro/resume_on.hpp +105 -0
  77. digraphx-0.3/cpp_ai/include/cppcoro/round_robin_scheduler.hpp +96 -0
  78. digraphx-0.3/cpp_ai/include/cppcoro/schedule_on.hpp +59 -0
  79. digraphx-0.3/cpp_ai/include/cppcoro/sequence_barrier.hpp +401 -0
  80. digraphx-0.3/cpp_ai/include/cppcoro/sequence_range.hpp +99 -0
  81. digraphx-0.3/cpp_ai/include/cppcoro/sequence_traits.hpp +26 -0
  82. digraphx-0.3/cpp_ai/include/cppcoro/shared_task.hpp +388 -0
  83. digraphx-0.3/cpp_ai/include/cppcoro/single_consumer_async_auto_reset_event.hpp +86 -0
  84. digraphx-0.3/cpp_ai/include/cppcoro/single_consumer_event.hpp +102 -0
  85. digraphx-0.3/cpp_ai/include/cppcoro/single_producer_sequencer.hpp +204 -0
  86. digraphx-0.3/cpp_ai/include/cppcoro/static_thread_pool.hpp +106 -0
  87. digraphx-0.3/cpp_ai/include/cppcoro/sync_wait.hpp +33 -0
  88. digraphx-0.3/cpp_ai/include/cppcoro/task.hpp +374 -0
  89. digraphx-0.3/cpp_ai/include/cppcoro/when_all.hpp +84 -0
  90. digraphx-0.3/cpp_ai/include/cppcoro/when_all_ready.hpp +51 -0
  91. digraphx-0.3/cpp_ai/include/cppcoro/writable_file.hpp +61 -0
  92. digraphx-0.3/cpp_ai/include/cppcoro/write_only_file.hpp +60 -0
  93. digraphx-0.3/cpp_ai/include/digraphx/min_cycle_ratio.hpp +193 -0
  94. digraphx-0.3/cpp_ai/include/digraphx/min_parmetric_q.hpp +164 -0
  95. digraphx-0.3/cpp_ai/include/digraphx/neg_cycle.hpp +245 -0
  96. digraphx-0.3/cpp_ai/include/digraphx/neg_cycle_q.hpp +308 -0
  97. digraphx-0.3/cpp_ai/include/digraphx/parametric.hpp +139 -0
  98. digraphx-0.3/cpp_ai/include/digraphx/tiny_digraph.hpp +364 -0
  99. digraphx-0.3/cpp_ai/include/digraphx/types.hpp +198 -0
  100. digraphx-0.3/cpp_ai/src/min_cycle_ratio.cpp +7 -0
  101. digraphx-0.3/cpp_ai/src/min_parmetric_q.cpp +6 -0
  102. digraphx-0.3/cpp_ai/src/neg_cycle.cpp +4 -0
  103. digraphx-0.3/cpp_ai/src/neg_cycle_q.cpp +4 -0
  104. digraphx-0.3/cpp_ai/src/parametric.cpp +4 -0
  105. digraphx-0.3/cpp_ai/src/tiny_digraph.cpp +4 -0
  106. digraphx-0.3/cpp_ai/tests/integration_tests.cpp +156 -0
  107. digraphx-0.3/cpp_ai/tests/test_neg_cycle.cpp +134 -0
  108. digraphx-0.3/cpp_ai/tests/test_tiny_digraph.cpp +160 -0
  109. digraphx-0.3/cpp_ai/xmake.lua +69 -0
  110. {digraphx-0.1 → digraphx-0.3}/docs/conf.py +19 -8
  111. {digraphx-0.1 → digraphx-0.3}/docs/requirements.txt +2 -0
  112. {digraphx-0.1 → digraphx-0.3}/mypy.ini +0 -6
  113. {digraphx-0.1 → digraphx-0.3}/requirements/test.txt +1 -0
  114. digraphx-0.3/rust_ai/.gitignore +88 -0
  115. digraphx-0.3/rust_ai/Cargo.toml +22 -0
  116. digraphx-0.3/rust_ai/examples/basic_usage.rs +62 -0
  117. digraphx-0.3/rust_ai/src/lib.rs +49 -0
  118. digraphx-0.3/rust_ai/src/min_cycle_ratio.rs +215 -0
  119. digraphx-0.3/rust_ai/src/min_parmetric_q.rs +170 -0
  120. digraphx-0.3/rust_ai/src/neg_cycle.rs +344 -0
  121. digraphx-0.3/rust_ai/src/neg_cycle_q.rs +452 -0
  122. digraphx-0.3/rust_ai/src/parametric.rs +172 -0
  123. digraphx-0.3/rust_ai/src/tiny_digraph.rs +255 -0
  124. digraphx-0.3/rust_ai/tests/integration_tests.rs +49 -0
  125. digraphx-0.3/src/digraphx/min_cycle_ratio.py +244 -0
  126. digraphx-0.3/src/digraphx/min_parametric_q.py +194 -0
  127. digraphx-0.3/src/digraphx/neg_cycle.py +326 -0
  128. digraphx-0.3/src/digraphx/neg_cycle_q.py +404 -0
  129. digraphx-0.3/src/digraphx/parametric.py +200 -0
  130. digraphx-0.3/src/digraphx/tiny_digraph.py +259 -0
  131. digraphx-0.3/src/digraphx.egg-info/PKG-INFO +230 -0
  132. digraphx-0.3/src/digraphx.egg-info/SOURCES.txt +186 -0
  133. digraphx-0.3/tests/__init__.py +0 -0
  134. digraphx-0.3/tests/conftest.py +63 -0
  135. digraphx-0.3/tests/test_cycle_ratio.py +158 -0
  136. digraphx-0.3/tests/test_delay_padding_example_howard.py +128 -0
  137. digraphx-0.3/tests/test_edge_cases.py +264 -0
  138. digraphx-0.3/tests/test_howard_cycle_cancellation.py +83 -0
  139. digraphx-0.3/tests/test_min_cycle_ratio_property.py +195 -0
  140. digraphx-0.3/tests/test_min_parametric_q.py +431 -0
  141. digraphx-0.3/tests/test_neg_cycle.py +114 -0
  142. digraphx-0.3/tests/test_neg_cycle_q.py +150 -0
  143. digraphx-0.3/tests/test_neg_cycle_q_simple_timing.py +38 -0
  144. digraphx-0.3/tests/test_neg_cycle_simple_timing.py +34 -0
  145. digraphx-0.3/tests/test_parametric.py +120 -0
  146. digraphx-0.3/tests/test_stress.py +209 -0
  147. digraphx-0.3/tests/test_timing_example.py +47 -0
  148. digraphx-0.3/tests/test_timing_example_howard.py +153 -0
  149. digraphx-0.3/tests/test_tiny_digraph.py +107 -0
  150. digraphx-0.3/tests/test_tiny_digraph_property.py +198 -0
  151. digraphx-0.1/PKG-INFO +0 -56
  152. digraphx-0.1/README.md +0 -33
  153. digraphx-0.1/src/digraphx/max_cycle_ratio.tpy +0 -134
  154. digraphx-0.1/src/digraphx/min_cycle_ratio.py +0 -174
  155. digraphx-0.1/src/digraphx/min_parmetric_q.py +0 -150
  156. digraphx-0.1/src/digraphx/neg_cycle.py +0 -241
  157. digraphx-0.1/src/digraphx/neg_cycle_q.py +0 -342
  158. digraphx-0.1/src/digraphx/parametric.py +0 -135
  159. digraphx-0.1/src/digraphx/skeleton.py +0 -149
  160. digraphx-0.1/src/digraphx/tiny_digraph.py +0 -79
  161. digraphx-0.1/src/digraphx.egg-info/PKG-INFO +0 -56
  162. digraphx-0.1/src/digraphx.egg-info/SOURCES.txt +0 -62
  163. digraphx-0.1/tests/conftest.py +0 -10
  164. digraphx-0.1/tests/test_cycle_ratio.py +0 -81
  165. digraphx-0.1/tests/test_neg_cycle.py +0 -139
  166. digraphx-0.1/tests/test_neg_cycle_q.py +0 -188
  167. digraphx-0.1/tests/test_skeleton.py +0 -25
  168. digraphx-0.1/tests/travis_install.sh +0 -60
  169. {digraphx-0.1 → digraphx-0.3}/.coveragerc +0 -0
  170. {digraphx-0.1 → digraphx-0.3}/.github/workflows/ci.bak +0 -0
  171. {digraphx-0.1 → digraphx-0.3}/.github/workflows/jekyll-gh-pages.yml +0 -0
  172. {digraphx-0.1 → digraphx-0.3}/.github/workflows/python-app.yml +0 -0
  173. {digraphx-0.1 → digraphx-0.3}/.github/workflows/python-publish.yml +0 -0
  174. {digraphx-0.1 → digraphx-0.3}/.gitignore +0 -0
  175. {digraphx-0.1 → digraphx-0.3}/.isort.cfg +0 -0
  176. {digraphx-0.1 → digraphx-0.3}/.readthedocs.yml +0 -0
  177. {digraphx-0.1 → digraphx-0.3}/AUTHORS.md +0 -0
  178. {digraphx-0.1 → digraphx-0.3}/CHANGELOG.md +0 -0
  179. {digraphx-0.1 → digraphx-0.3}/LICENSE +0 -0
  180. {digraphx-0.1 → digraphx-0.3}/docs/Makefile +0 -0
  181. {digraphx-0.1 → digraphx-0.3}/docs/_static/.gitignore +0 -0
  182. {digraphx-0.1 → digraphx-0.3}/docs/authors.md +0 -0
  183. {digraphx-0.1 → digraphx-0.3}/docs/changelog.md +0 -0
  184. {digraphx-0.1 → digraphx-0.3}/docs/contributing.md +0 -0
  185. {digraphx-0.1 → digraphx-0.3}/docs/index.md +0 -0
  186. {digraphx-0.1 → digraphx-0.3}/docs/license.md +0 -0
  187. {digraphx-0.1 → digraphx-0.3}/docs/readme.md +0 -0
  188. {digraphx-0.1 → digraphx-0.3}/environment.yml +0 -0
  189. {digraphx-0.1 → digraphx-0.3}/experiments/plot_node_colormap.ipynb +0 -0
  190. {digraphx-0.1 → digraphx-0.3}/experiments/plot_node_colormap.py +0 -0
  191. {digraphx-0.1 → digraphx-0.3}/note.md +0 -0
  192. {digraphx-0.1 → digraphx-0.3}/pyproject.toml +0 -0
  193. {digraphx-0.1 → digraphx-0.3}/requirements/README.md +0 -0
  194. {digraphx-0.1 → digraphx-0.3}/requirements/default.txt +0 -0
  195. {digraphx-0.1 → digraphx-0.3}/requirements/doc.txt +0 -0
  196. {digraphx-0.1 → digraphx-0.3}/requirements.txt +0 -0
  197. {digraphx-0.1 → digraphx-0.3}/setup.cfg +0 -0
  198. {digraphx-0.1 → digraphx-0.3}/setup.py +0 -0
  199. {digraphx-0.1 → digraphx-0.3}/src/digraphx/__init__.py +0 -0
  200. /digraphx-0.1/tests/__init__.py → /digraphx-0.3/src/digraphx/py.typed +0 -0
  201. {digraphx-0.1 → digraphx-0.3}/src/digraphx.egg-info/dependency_links.txt +0 -0
  202. {digraphx-0.1 → digraphx-0.3}/src/digraphx.egg-info/not-zip-safe +0 -0
  203. {digraphx-0.1 → digraphx-0.3}/src/digraphx.egg-info/requires.txt +0 -0
  204. {digraphx-0.1 → digraphx-0.3}/src/digraphx.egg-info/top_level.txt +0 -0
  205. {digraphx-0.1 → digraphx-0.3}/tox.ini +0 -0
@@ -8,10 +8,10 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  os: ["ubuntu-latest", "windows-latest"]
11
- version: ["3.9", "3.12"]
11
+ version: ["3.9", "3.11"]
12
12
  steps:
13
- - uses: actions/checkout@v2
14
- - uses: conda-incubator/setup-miniconda@v2
13
+ - uses: actions/checkout@v3
14
+ - uses: conda-incubator/setup-miniconda@v3
15
15
  with:
16
16
  activate-environment: test
17
17
  environment-file: environment.yml
@@ -31,8 +31,9 @@ jobs:
31
31
  shell: bash -l {0}
32
32
  run: |
33
33
  conda install pytest
34
- python -m pip install --upgrade pip
34
+ conda install pip
35
+ conda install setuptools wheel setuptools_scm
35
36
  if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36
37
  pip install git+https://github.com/luk036/mywheel.git
37
- python setup.py develop
38
+ pip install -e .
38
39
  pytest
@@ -14,8 +14,10 @@ repos:
14
14
  - id: debug-statements
15
15
  - id: end-of-file-fixer
16
16
  - id: requirements-txt-fixer
17
+ exclude: "requirements[.]txt$"
17
18
  - id: mixed-line-ending
18
19
  args: ["--fix=auto"] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
20
+ exclude: "requirements[.]txt$"
19
21
 
20
22
  ## If you want to automatically "modernize" your Python code:
21
23
  # - repo: https://github.com/asottile/pyupgrade
@@ -0,0 +1,3 @@
1
+ {
2
+ "cmake.sourceDirectory": "D:/github/py/digraphx/cpp_ai"
3
+ }
digraphx-0.3/AGENTS.md ADDED
@@ -0,0 +1,127 @@
1
+ # AGENTS.md
2
+
3
+ This file guides agentic coding assistants working in the digraphx repository.
4
+
5
+ ## Build / Lint / Test Commands
6
+
7
+ ```bash
8
+ # Run all tests with coverage
9
+ pytest
10
+
11
+ # Run single test file
12
+ pytest tests/test_tiny_digraph.py
13
+
14
+ # Run specific test
15
+ pytest tests/test_tiny_digraph.py::test_tiny_digraph
16
+
17
+ # Run tests matching pattern
18
+ pytest -k "tiny_digraph"
19
+
20
+ # Build package
21
+ tox -e build
22
+
23
+ # Run linting (pre-commit)
24
+ pre-commit run --all-files
25
+
26
+ # Run specific lint tools
27
+ black src/digraphx tests
28
+ isort src/digraphx tests
29
+ flake8 src/digraphx tests
30
+ ```
31
+
32
+ **Testing Notes:**
33
+ - Tests located in `tests/` directory
34
+ - Pytest configured in `setup.cfg` with coverage enabled
35
+ - Fixtures defined in `tests/conftest.py`
36
+ - Use `-k` flag to run tests matching name pattern
37
+
38
+ ## Code Style Guidelines
39
+
40
+ ### Formatting
41
+ - **Line length**: 256 characters (flake8 config)
42
+ - **Formatter**: Black (auto-enforced via pre-commit)
43
+ - **Import sorting**: isort (auto-enforced via pre-commit)
44
+ - **Linting**: flake8 with E203, W503 ignored (Black-compatible)
45
+
46
+ ### Type Hints
47
+ - **Required**: All functions must use type hints
48
+ - **Imports**: Use `from typing import List, Dict, Set, Tuple, Optional, Union, Generic, TypeVar, Callable, Mapping, MutableMapping, Iterator, Generator`
49
+ - **Generic types**: Use TypeVar for generic classes (e.g., `Node = TypeVar("Node")`)
50
+ - **External deps**: Use `# type: ignore` for missing stub files (e.g., `from mywheel.map_adapter import MapAdapter # type: ignore`)
51
+
52
+ ### Naming Conventions
53
+ - **Classes**: PascalCase (TinyDiGraph, NegCycleFinder, MinCycleRatioSolver)
54
+ - **Functions/methods**: snake_case (init_nodes, find_cycle, howard)
55
+ - **Constants**: UPPER_SNAKE_CASE (WEIGHT_0_1, SELF_LOOP_WEIGHT, NUM_NODES)
56
+ - **Private methods**: underscore prefix (`_helper_function`)
57
+ - **Type aliases**: PascalCase or short caps (Node, Edge, Domain, Cycle)
58
+
59
+ ### Documentation
60
+ - **Docstrings**: Required for all public classes and methods
61
+ - **Style**: Google-style with Args, Returns, Examples sections
62
+ - **Examples**: Include doctest-style examples for key methods
63
+ - **Module docstrings**: Describe purpose, inputs, outputs, algorithms used
64
+
65
+ ### Error Handling
66
+ - Use type annotations for validation (e.g., `Mapping[Node, Edge]`)
67
+ - Avoid empty catch blocks
68
+ - Use pytest.raises for testing expected exceptions
69
+ - Raise specific exceptions (NotImplementedError, ValueError, TypeError)
70
+
71
+ ### Import Style
72
+ ```python
73
+ # Standard library imports first
74
+ from fractions import Fraction
75
+ from typing import List, Dict, TypeVar
76
+
77
+ # Third-party imports second
78
+ import networkx as nx
79
+
80
+ # Local imports third (relative preferred within package)
81
+ from .neg_cycle import NegCycleFinder
82
+ from digraphx.tiny_digraph import TinyDiGraph
83
+ ```
84
+
85
+ ### Code Patterns
86
+ - Use generics for reusable components: `class Solver(Generic[Node, Edge, Ratio]):`
87
+ - Prefer composition over inheritance
88
+ - Use generators for large sequences: `def find_cycle() -> Generator[Node, None, None]:`
89
+ - Use dataclasses or named tuples for structured data
90
+ - Mutable and immutable types: Separate Mapping (immutable) from MutableMapping (mutable)
91
+
92
+ ### Graph-Specific Conventions
93
+ - Node identifiers: Generic hashable types (int, str, tuple)
94
+ - Edge data: MutableMapping[str, Any] for attributes
95
+ - Use NetworkX DiGraph patterns extended with custom storage
96
+ - Separate graph structure from algorithms (adapter pattern)
97
+ - Use fractional arithmetic for exact ratios (from fractions import Fraction)
98
+
99
+ ## Project Structure
100
+ ```
101
+ src/digraphx/ # Main package
102
+ ├── __init__.py # Version info, exports
103
+ ├── tiny_digraph.py # Graph data structures
104
+ ├── neg_cycle.py # Negative cycle algorithms
105
+ ├── parametric.py # Parametric solver framework
106
+ └── min_cycle_ratio.py # Minimum cycle ratio solver
107
+
108
+ tests/ # Test suite
109
+ ├── conftest.py # Shared fixtures
110
+ └── test_*.py # Test files
111
+
112
+ setup.cfg # Package config, pytest options
113
+ pyproject.toml # Build config
114
+ .pre-commit-config.yaml # Linting hooks
115
+ ```
116
+
117
+ ## Dependencies
118
+ - **networkx**: Graph library base
119
+ - **luk036/mywheel**: Custom utilities (MapAdapter)
120
+ - Testing: pytest, pytest-cov
121
+ - Development: black, isort, flake8, pre-commit
122
+
123
+ ## Key Algorithms
124
+ - **Howard's algorithm**: Negative cycle detection
125
+ - **Bellman-Ford**: Shortest paths with negative edges
126
+ - **Parametric optimization**: Maximize/minimize ratio-based objectives
127
+ - **Cycle ratio**: Find cycle with minimum/maximum cost/time ratio
@@ -1,31 +1,3 @@
1
- ```{todo} THIS IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS!
2
-
3
- The document assumes you are using a source repository service that promotes a
4
- contribution model similar to [GitHub's fork and pull request workflow].
5
- While this is true for the majority of services (like GitHub, GitLab,
6
- BitBucket), it might not be the case for private repositories (e.g., when
7
- using Gerrit).
8
-
9
- Also notice that the code examples might refer to GitHub URLs or the text
10
- might use GitHub specific terminology (e.g., *Pull Request* instead of *Merge
11
- Request*).
12
-
13
- Please make sure to check the document having these assumptions in mind
14
- and update things accordingly.
15
- ```
16
-
17
- ```{todo} Provide the correct links/replacements at the bottom of the document.
18
-
19
- ```
20
-
21
- ```{todo} You might want to have a look on [PyScaffold's contributor's guide],
22
-
23
- especially if your project is open source. The text should be very similar to
24
- this template, but there are a few extra contents that you might decide to
25
- also include, like mentioning labels of your issue tracker or automated
26
- releases.
27
- ```
28
-
29
1
  # Contributing
30
2
 
31
3
  Welcome to `digraphx` contributor's guide.
@@ -69,29 +41,6 @@ by adding missing information and correcting mistakes.
69
41
  This means that the docs are kept in the same repository as the project code, and
70
42
  that any documentation update is done in the same way was a code contribution.
71
43
 
72
- ```{todo} Don't forget to mention which markup language you are using.
73
-
74
- e.g., [reStructuredText] or [CommonMark] with [MyST] extensions.
75
- ```
76
-
77
- ```{todo} If your project is hosted on GitHub, you can also mention the following tip:
78
-
79
- :::{tip}
80
- Please notice that the [GitHub web interface] provides a quick way of
81
- propose changes in `digraphx`'s files. While this mechanism can
82
- be tricky for normal code contributions, it works perfectly fine for
83
- contributing to the docs, and can be quite handy.
84
-
85
- If you are interested in trying this method out, please navigate to
86
- the `docs` folder in the source [repository], find which file you
87
- would like to propose changes and click in the little pencil icon at the
88
- top, to open [GitHub's code editor]. Once you finish editing the file,
89
- please write a message in the form at the bottom of the page describing
90
- which changes have you made and what are the motivations behind them and
91
- submit your proposal.
92
- :::
93
- ```
94
-
95
44
  When working on documentation changes in your local machine, you can
96
45
  compile them using [tox] :
97
46
 
@@ -108,13 +57,6 @@ python3 -m http.server --directory 'docs/_build/html'
108
57
 
109
58
  ## Code Contributions
110
59
 
111
- ```{todo} Please include a reference or explanation about the internals of the project.
112
-
113
- An architecture description, design principles or at least a summary of the
114
- main concepts will make it easy for potential contributors to get started
115
- quickly.
116
- ```
117
-
118
60
  ### Submit an issue
119
61
 
120
62
  Before you work on any non-trivial code contribution it's best to first create
@@ -161,10 +103,6 @@ conda activate digraphx
161
103
 
162
104
  to be able to import the package under development in the Python REPL.
163
105
 
164
- ```{todo} if you are not using pre-commit, please remove the following item:
165
-
166
- ```
167
-
168
106
  5. Install [pre-commit]:
169
107
 
170
108
  ```
@@ -199,10 +137,6 @@ conda activate digraphx
199
137
 
200
138
  to record your changes in [git].
201
139
 
202
- ```{todo} if you are not using pre-commit, please remove the following item:
203
-
204
- ```
205
-
206
140
  Please make sure to see the validation messages from [pre-commit] and fix
207
141
  any eventual issues.
208
142
  This should automatically use [flake8]/[black] to check/fix the code style
@@ -244,14 +178,6 @@ conda activate digraphx
244
178
  2. Go to the web page of your fork and click "Create pull request"
245
179
  to send your changes for review.
246
180
 
247
- ```{todo} if you are using GitHub, you can uncomment the following paragraph
248
-
249
- Find more detailed information in [creating a PR]. You might also want to open
250
- the PR as a draft first and mark it as ready for review after the feedbacks
251
- from the continuous integration (CI) system or any required fixes.
252
-
253
- ```
254
-
255
181
  ### Troubleshooting
256
182
 
257
183
  The following tips can be used when facing problems to build or test the
@@ -309,12 +235,6 @@ package:
309
235
 
310
236
  ### Releases
311
237
 
312
- ```{todo} This section assumes you are using PyPI to publicly release your package.
313
-
314
- If instead you are using a different/private package index, please update
315
- the instructions accordingly.
316
- ```
317
-
318
238
  If you are part of the group of maintainers and have correct user permissions
319
239
  on [PyPI], the following steps can be used to release a new version for
320
240
  `digraphx`:
@@ -366,9 +286,5 @@ on [PyPI], the following steps can be used to release a new version for
366
286
  [virtual environment]: https://realpython.com/python-virtual-environments-a-primer/
367
287
  [virtualenv]: https://virtualenv.pypa.io/en/stable/
368
288
 
369
- ```{todo} Please review and change the following definitions:
370
-
371
- ```
372
-
373
- [repository]: https://github.com/<USERNAME>/digraphx
374
- [issue tracker]: https://github.com/<USERNAME>/digraphx/issues
289
+ [repository]: https://github.com/luk036/digraphx
290
+ [issue tracker]: https://github.com/luk036/digraphx/issues
digraphx-0.3/GEMINI.md ADDED
@@ -0,0 +1,65 @@
1
+ # Gemini Code Assistant Context
2
+
3
+ ## Project Overview
4
+
5
+ This project, `digraphx`, is a Python library for network optimization on directed graphs. It provides algorithms for finding minimum cycle ratios, solving parametric network problems, and detecting negative cycles using Howard's algorithm. The library is built on top of `networkx` but includes a custom `TinyDiGraph` data structure for improved memory efficiency with large graphs.
6
+
7
+ The project is structured as a standard Python library using a `src` layout and is configured with `setup.cfg` and `pyproject.toml`.
8
+
9
+ ### Key Technologies
10
+
11
+ * **Language:** Python
12
+ * **Core Library:** `networkx`
13
+ * **Testing:** `pytest`, `pytest-cov`, `tox`
14
+ * **Code Style:** `flake8`, `pre-commit`
15
+
16
+ ### Core Modules
17
+
18
+ * `min_cycle_ratio.py`: Implements the Minimum Cycle Ratio (MCR) solver.
19
+ * `parametric.py` & `min_parametric_q.py`: Implements solvers for parametric network problems.
20
+ * `neg_cycle.py` & `neg_cycle_q.py`: Implements negative cycle detection using Howard's algorithm.
21
+ * `tiny_digraph.py`: Defines a memory-efficient `TinyDiGraph` data structure.
22
+
23
+ ## Building and Running
24
+
25
+ This is a library, so there is no main application to run. However, you can install it and run tests.
26
+
27
+ ### Installation
28
+
29
+ To install the project in editable mode, use the following command:
30
+
31
+ ```bash
32
+ pip install -e .
33
+ ```
34
+
35
+ ### Running Tests
36
+
37
+ The project uses `pytest` for testing. To run the tests, use the following command:
38
+
39
+ ```bash
40
+ pytest
41
+ ```
42
+
43
+ You can also use `tox` to run tests in different Python environments:
44
+
45
+ ```bash
46
+ tox
47
+ ```
48
+
49
+ ## Development Conventions
50
+
51
+ ### Code Style
52
+
53
+ The project uses `flake8` for linting and `pre-commit` to enforce code style. Before committing any changes, make sure to run `pre-commit`:
54
+
55
+ ```bash
56
+ pre-commit run --all-files
57
+ ```
58
+
59
+ ### Testing
60
+
61
+ All new features should be accompanied by tests. The tests are located in the `tests` directory and follow the standard `pytest` conventions.
62
+
63
+ ### Contribution Guidelines
64
+
65
+ The `CONTRIBUTING.md` file provides guidelines for contributing to the project. Please review it before making any contributions.
digraphx-0.3/IFLOW.md ADDED
@@ -0,0 +1,103 @@
1
+ # digraphx 项目上下文
2
+
3
+ ## 项目概述
4
+
5
+ `digraphx` 是一个用 Python 编写的有向图(Directed Graph)优化库,专注于网络优化问题。该项目基于 PyScaffold 4.5 创建,旨在提供一个轻量级且高效的有向图操作和分析工具。
6
+
7
+ 主要特性包括:
8
+ - 负环检测(Negative Cycle Detection)
9
+ - 最小环比率计算(Minimum Cycle Ratio Calculation)
10
+ - 参数化优化算法
11
+ - 高效的图数据结构实现(TinyDiGraph)
12
+
13
+ ## 依赖关系
14
+
15
+ - [luk036/mywheel](https://github.com/luk036/mywheel) - 自定义数据结构库
16
+ - networkx - 图论算法库
17
+ - decorator
18
+ - numpy
19
+
20
+ ## 核心模块
21
+
22
+ ### 1. TinyDiGraph (`tiny_digraph.py`)
23
+ 一个轻量级的有向图实现,优化了性能和内存效率。通过继承自 NetworkX 的 DiGraph 类,并使用自定义的 MapAdapter 作为底层存储结构。
24
+
25
+ ### 2. 负环检测 (`neg_cycle.py`)
26
+ 实现了基于 Howard 方法的负环检测算法,使用 Bellman-Ford 算法进行边的松弛操作。
27
+
28
+ ### 3. 最小环比率求解器 (`min_cycle_ratio.py`)
29
+ 提供最小环比率问题的求解,使用参数化方法结合最大参数化求解器。
30
+
31
+ ### 4. 其他模块
32
+ - `min_parametric_q.py` - 参数化 Q 优化
33
+ - `neg_cycle_q.py` - 负环 Q 检测
34
+ - `parametric.py` - 参数化算法接口
35
+
36
+ ## 构建和测试
37
+
38
+ 该项目使用标准的 Python 包管理工具:
39
+
40
+ 安装依赖:
41
+ ```bash
42
+ pip install -r requirements/default.txt
43
+ pip install -r requirements/test.txt
44
+ ```
45
+
46
+ 运行测试:
47
+ ```bash
48
+ pytest tests/
49
+ ```
50
+
51
+ 代码覆盖率测试:
52
+ ```bash
53
+ pytest --cov digraphx --cov-report term-missing
54
+ ```
55
+
56
+ ## 开发规范
57
+
58
+ - 代码使用 Python 3.9+ 编写
59
+ - 遵循 PEP 8 代码风格
60
+ - 使用 type hints 提供类型信息
61
+ - 测试使用 pytest 框架
62
+
63
+ ## 项目结构
64
+
65
+ ```
66
+ src/digraphx/ - 源代码目录
67
+ ├── __init__.py
68
+ ├── tiny_digraph.py - 轻量级有向图实现
69
+ ├── neg_cycle.py - 负环检测算法
70
+ ├── min_cycle_ratio.py - 最小环比率求解器
71
+ ├── parametric.py - 参数化算法接口
72
+ ├── neg_cycle_q.py - 负环 Q 检测
73
+ ├── min_parametric_q.py - 参数化 Q 优化
74
+ └── py.typed - 类型提示标记文件
75
+
76
+ tests/ - 测试目录
77
+ ├── test_cycle_ratio.py - 环比率相关测试
78
+ ├── test_neg_cycle.py - 负环检测测试
79
+ ├── test_tiny_digraph.py - TinyDiGraph 测试
80
+ └── 其他测试文件
81
+ ```
82
+
83
+ ## 使用示例
84
+
85
+ 从 TinyDiGraph 的文档可以看出,基本用法如下:
86
+
87
+ ```python
88
+ from digraphx.tiny_digraph import TinyDiGraph
89
+
90
+ digraph = TinyDiGraph()
91
+ digraph.init_nodes(1000) # 初始化 1000 个节点
92
+ digraph.add_edge(2, 1) # 添加从节点 2 到节点 1 的边
93
+ ```
94
+
95
+ ## 项目状态
96
+
97
+ 根据 setup.cfg 中的分类器,该项目处于 Beta 开发阶段,使用 MIT 许可证。
98
+
99
+ ## 备注
100
+
101
+ - 该项目专注于网络优化算法,特别是负环检测和最小环比率问题
102
+ - 使用了自定义的高效数据结构以优化性能
103
+ - 与 NetworkX 集成,利用其丰富的图算法功能
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Wai-Shing Luk
3
+ Copyright (c) 2025 Wai-Shing Luk
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal