diff options
| -rw-r--r-- | drawer/.gitignore | 10 | ||||
| -rw-r--r-- | drawer/README.md | 3 | ||||
| -rw-r--r-- | drawer/pyproject.toml | 30 | ||||
| -rw-r--r-- | drawer/requirements-dev.lock | 37 | ||||
| -rw-r--r-- | drawer/requirements.lock | 37 | ||||
| -rw-r--r-- | drawer/src/drawer/__init__.py | 24 |
6 files changed, 141 insertions, 0 deletions
diff --git a/drawer/.gitignore b/drawer/.gitignore new file mode 100644 index 0000000..ae8554d --- /dev/null +++ b/drawer/.gitignore @@ -0,0 +1,10 @@ +# python generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# venv +.venv diff --git a/drawer/README.md b/drawer/README.md new file mode 100644 index 0000000..ec1579b --- /dev/null +++ b/drawer/README.md @@ -0,0 +1,3 @@ +# drawer + +Describe your project here. diff --git a/drawer/pyproject.toml b/drawer/pyproject.toml new file mode 100644 index 0000000..04acc19 --- /dev/null +++ b/drawer/pyproject.toml @@ -0,0 +1,30 @@ +[project] +name = "drawer" +version = "0.1.0" +description = "Add your description here" +authors = [ + { name = "Andrew Guschin", email = "guschin@altlinux.org" } +] +dependencies = [ + "networkx>=3.4.2", + "matplotlib>=3.9.2", +] +readme = "README.md" +requires-python = ">= 3.8" + +[project.scripts] +start = "drawer:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.rye] +managed = true +dev-dependencies = [] + +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.wheel] +packages = ["src/drawer"] diff --git a/drawer/requirements-dev.lock b/drawer/requirements-dev.lock new file mode 100644 index 0000000..94671b2 --- /dev/null +++ b/drawer/requirements-dev.lock @@ -0,0 +1,37 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false +# generate-hashes: false +# universal: false + +-e file:. +contourpy==1.3.0 + # via matplotlib +cycler==0.12.1 + # via matplotlib +fonttools==4.54.1 + # via matplotlib +kiwisolver==1.4.7 + # via matplotlib +matplotlib==3.9.2 + # via drawer +networkx==3.4.2 + # via drawer +numpy==2.1.2 + # via contourpy + # via matplotlib +packaging==24.1 + # via matplotlib +pillow==11.0.0 + # via matplotlib +pyparsing==3.2.0 + # via matplotlib +python-dateutil==2.9.0.post0 + # via matplotlib +six==1.16.0 + # via python-dateutil diff --git a/drawer/requirements.lock b/drawer/requirements.lock new file mode 100644 index 0000000..94671b2 --- /dev/null +++ b/drawer/requirements.lock @@ -0,0 +1,37 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false +# generate-hashes: false +# universal: false + +-e file:. +contourpy==1.3.0 + # via matplotlib +cycler==0.12.1 + # via matplotlib +fonttools==4.54.1 + # via matplotlib +kiwisolver==1.4.7 + # via matplotlib +matplotlib==3.9.2 + # via drawer +networkx==3.4.2 + # via drawer +numpy==2.1.2 + # via contourpy + # via matplotlib +packaging==24.1 + # via matplotlib +pillow==11.0.0 + # via matplotlib +pyparsing==3.2.0 + # via matplotlib +python-dateutil==2.9.0.post0 + # via matplotlib +six==1.16.0 + # via python-dateutil diff --git a/drawer/src/drawer/__init__.py b/drawer/src/drawer/__init__.py new file mode 100644 index 0000000..ef47fbc --- /dev/null +++ b/drawer/src/drawer/__init__.py @@ -0,0 +1,24 @@ +import networkx as nx +import tempfile + +def main(): + g6 = "I?opuIiBw" + with tempfile.NamedTemporaryFile(delete=False) as f: + _ = f.write(g6.encode()) + _ = f.seek(0) + g = nx.read_graph6(f.name) + + tikz_options = "scale=4" + node_options = {n: "line width=1.5, draw=black, circle" for n in g.nodes} + edge_options = {e: "line width=1.5" for e in g.edges} + print(nx.to_latex( + g, nx.circular_layout(g), + caption=f"Визуализация графа <<{g6}>>", + figure_wrapper='\\begin{{figure}}\\centering\n{content}{caption}{label}\n\\end{{figure}}', + as_document=False, + tikz_options=tikz_options, + node_options=node_options, + edge_options=edge_options + )) + # nx.write_latex(g, "graph.tex", as_document=True) + # nx.draw(g) |