pygraphds 0.1.1__tar.gz → 0.1.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.
- {pygraphds-0.1.1/src/pygraphds.egg-info → pygraphds-0.1.3}/PKG-INFO +1 -1
- {pygraphds-0.1.1 → pygraphds-0.1.3}/pyproject.toml +1 -1
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds/__init__.py +1 -1
- pygraphds-0.1.3/src/pygraphds/_version.py +3 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds/graph.py +15 -9
- {pygraphds-0.1.1 → pygraphds-0.1.3/src/pygraphds.egg-info}/PKG-INFO +1 -1
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds.egg-info/SOURCES.txt +1 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/LICENSE +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/README.md +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/setup.cfg +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds.egg-info/dependency_links.txt +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds.egg-info/requires.txt +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/src/pygraphds.egg-info/top_level.txt +0 -0
- {pygraphds-0.1.1 → pygraphds-0.1.3}/tests/test_graph.py +0 -0
|
@@ -7,6 +7,8 @@ from copy import deepcopy
|
|
|
7
7
|
import math
|
|
8
8
|
from typing import Optional
|
|
9
9
|
|
|
10
|
+
from ._version import __version__
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
class Graph:
|
|
12
14
|
"""Store an undirected graph with string-named nodes.
|
|
@@ -15,6 +17,9 @@ class Graph:
|
|
|
15
17
|
duplicate edges are not allowed. Nodes and edges keep the order in which
|
|
16
18
|
they were added.
|
|
17
19
|
|
|
20
|
+
The loaded library version is available as ``Graph.__version__`` and
|
|
21
|
+
``graph.__version__``.
|
|
22
|
+
|
|
18
23
|
Node and edge data are stored as supplied. The getters return those same
|
|
19
24
|
data objects; :meth:`copy` makes a deep, independent copy of the graph.
|
|
20
25
|
|
|
@@ -28,6 +33,8 @@ class Graph:
|
|
|
28
33
|
['B']
|
|
29
34
|
"""
|
|
30
35
|
|
|
36
|
+
__version__ = __version__
|
|
37
|
+
|
|
31
38
|
def __init__(self) -> None:
|
|
32
39
|
self._node_data: dict[str, object] = {}
|
|
33
40
|
self._adjacency: dict[str, list[str]] = {}
|
|
@@ -328,7 +335,8 @@ class Graph:
|
|
|
328
335
|
|
|
329
336
|
``crossing`` chooses the mark where differently directed edge strokes
|
|
330
337
|
meet: ``"x"`` (default), ``"+"``, or ``""`` for a blank. Nodes are
|
|
331
|
-
placed in a five
|
|
338
|
+
placed in a compact grid with at most five columns; edge strokes are
|
|
339
|
+
drawn behind labels.
|
|
332
340
|
"""
|
|
333
341
|
if crossing != "" and crossing != "+" and crossing != "x":
|
|
334
342
|
raise ValueError('crossing must be "", "+", or "x"')
|
|
@@ -345,7 +353,7 @@ class Graph:
|
|
|
345
353
|
)
|
|
346
354
|
labels[name] = "[" + visible_name + "]"
|
|
347
355
|
widest_label = max(len(label) for label in labels.values())
|
|
348
|
-
column_count = min(5, len(names))
|
|
356
|
+
column_count = min(5, math.ceil(len(names) / 2))
|
|
349
357
|
column_spacing = max(8, widest_label + 3)
|
|
350
358
|
row_spacing = 4
|
|
351
359
|
positions: dict[str, list[int]] = {}
|
|
@@ -374,10 +382,7 @@ class Graph:
|
|
|
374
382
|
else:
|
|
375
383
|
stroke = "/"
|
|
376
384
|
|
|
377
|
-
|
|
378
|
-
step_count = abs(dy)
|
|
379
|
-
else:
|
|
380
|
-
step_count = max(abs(dx), abs(dy))
|
|
385
|
+
step_count = max(abs(dx), abs(dy))
|
|
381
386
|
for step in range(1, step_count):
|
|
382
387
|
x = round(x1 + dx * step / step_count)
|
|
383
388
|
y = round(y1 + dy * step / step_count)
|
|
@@ -417,8 +422,9 @@ class Graph:
|
|
|
417
422
|
import matplotlib.pyplot as plt
|
|
418
423
|
except ImportError as error:
|
|
419
424
|
raise ImportError(
|
|
420
|
-
"Graph.show() requires Matplotlib
|
|
421
|
-
"with pygraphds. Check that
|
|
425
|
+
f"Graph.show() requires Matplotlib (pygraphds {self.__version__}). "
|
|
426
|
+
"Matplotlib should be installed with pygraphds. Check that "
|
|
427
|
+
"the package dependencies were installed."
|
|
422
428
|
) from error
|
|
423
429
|
|
|
424
430
|
names = list(self._node_data)
|
|
@@ -468,7 +474,7 @@ class Graph:
|
|
|
468
474
|
name,
|
|
469
475
|
ha="center",
|
|
470
476
|
va="center",
|
|
471
|
-
fontsize=
|
|
477
|
+
fontsize=11.25,
|
|
472
478
|
color="#172554",
|
|
473
479
|
zorder=3,
|
|
474
480
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|