summaryrefslogtreecommitdiff
path: root/drawer/src
diff options
context:
space:
mode:
authorAndrew Guschin <guschin@altlinux.org>2024-10-28 19:22:34 +0400
committerAndrew Guschin <guschin@altlinux.org>2024-10-28 19:25:29 +0400
commit4471a89bef824e9f9886228718fae99bff6c35e7 (patch)
tree47923493944b70d1044ba44473719d940829dacc /drawer/src
parent25d3c40871c9bca9e4bee1b767c8a1480d05c701 (diff)
feat: add program for visualizing graphs
Diffstat (limited to 'drawer/src')
-rw-r--r--drawer/src/drawer/__init__.py24
1 files changed, 24 insertions, 0 deletions
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)