kdedge 0.0.1__py3-none-any.whl
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.
- kdedge/__init__.py +43 -0
- kdedge/_shared.py +54 -0
- kdedge/algo.py +656 -0
- kdedge/helpers.py +42 -0
- kdedge/impl/__init__.py +0 -0
- kdedge/impl/impl_numba.py +436 -0
- kdedge/impl/impl_numpy.py +240 -0
- kdedge/impl/impl_scipy.py +23 -0
- kdedge/impl/registry.py +61 -0
- kdedge/kernels.py +284 -0
- kdedge/py.typed +0 -0
- kdedge-0.0.1.dist-info/METADATA +256 -0
- kdedge-0.0.1.dist-info/RECORD +17 -0
- kdedge-0.0.1.dist-info/WHEEL +5 -0
- kdedge-0.0.1.dist-info/licenses/LICENSE +21 -0
- kdedge-0.0.1.dist-info/top_level.txt +1 -0
- kdedge-0.0.1.dist-info/zip-safe +1 -0
kdedge/__init__.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Edge bundling algorithms for visualizing graphs.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__: str = "0.0.1"
|
|
7
|
+
__author__: str = "cuzi"
|
|
8
|
+
__email__: str = "cuzi@openmail.cc"
|
|
9
|
+
__source__: str = "https://github.com/cvzi/kdedge"
|
|
10
|
+
__license__: str = """
|
|
11
|
+
MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) cuzi 2025
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"bundle",
|
|
36
|
+
"exponential_schedule",
|
|
37
|
+
"kdeeb",
|
|
38
|
+
"linear_schedule",
|
|
39
|
+
"list_backends"
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
from .algo import bundle, exponential_schedule, kdeeb, linear_schedule
|
|
43
|
+
from .impl.registry import list_backends
|
kdedge/_shared.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from typing import Literal, TypeAlias
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
from numpy.typing import ArrayLike, NDArray
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"ArraySplatKernel",
|
|
12
|
+
"FloatArray",
|
|
13
|
+
"GridShape",
|
|
14
|
+
"SplatKernel",
|
|
15
|
+
"SplatKernelArrayFn",
|
|
16
|
+
"SplatKernelFn",
|
|
17
|
+
"as_float_array",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
EPS = 1e-12
|
|
21
|
+
|
|
22
|
+
FloatArray: TypeAlias = NDArray[np.floating]
|
|
23
|
+
GridShape: TypeAlias = tuple[int, int]
|
|
24
|
+
SplatKernelFn: TypeAlias = Callable[[float, float], float]
|
|
25
|
+
SplatKernelArrayFn: TypeAlias = Callable[[FloatArray, float], FloatArray]
|
|
26
|
+
AdvectEdgesFn: TypeAlias = Callable[
|
|
27
|
+
[
|
|
28
|
+
list[FloatArray], # polylines
|
|
29
|
+
FloatArray, # own_field
|
|
30
|
+
FloatArray | None, # node_grad
|
|
31
|
+
float, # attract
|
|
32
|
+
float, # node_repel
|
|
33
|
+
float, # smooth_lambda
|
|
34
|
+
int, # smooth_iterations
|
|
35
|
+
int, # h
|
|
36
|
+
int, # w
|
|
37
|
+
],
|
|
38
|
+
list[FloatArray],
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass(frozen=True)
|
|
43
|
+
class ArraySplatKernel:
|
|
44
|
+
fn: SplatKernelArrayFn
|
|
45
|
+
|
|
46
|
+
SplatKernel: TypeAlias = (
|
|
47
|
+
Literal["linear", "cone", "gaussian"] | SplatKernelFn | ArraySplatKernel | None
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def as_float_array(values: ArrayLike | float | int, *,
|
|
51
|
+
copy: bool = False) -> FloatArray:
|
|
52
|
+
if copy:
|
|
53
|
+
return np.array(values, dtype=np.float64, copy=True)
|
|
54
|
+
return np.asarray(values, dtype=np.float64)
|