simulation-alg 0.1.7__tar.gz → 0.1.8__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.
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/Cargo.lock +1 -1
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/Cargo.toml +1 -1
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/PKG-INFO +1 -1
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/pyproject.toml +1 -1
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/simulation.pyi +5 -1
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/src/lib.rs +3 -0
- simulation_alg-0.1.8/test.py +57 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/.github/workflows/ci.yml +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/.gitignore +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/.gitmodules +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/LICENSE +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/README.md +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/hyper-simulation.log +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/python/__init__.py +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/requirements.txt +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/src/graph/hypergraph.rs +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/src/graph/mod.rs +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/src/graph/networkx_graph.rs +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/src/utils.rs +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/tests/test_hyper_simulation.py +0 -0
- {simulation_alg-0.1.7 → simulation_alg-0.1.8}/tests/test_simulation.py +0 -0
|
@@ -50,6 +50,7 @@ class Hyperedge:
|
|
|
50
50
|
def desc(self) -> str: ...
|
|
51
51
|
|
|
52
52
|
|
|
53
|
+
# (cluster_u, cluster_v)
|
|
53
54
|
class DMatch:
|
|
54
55
|
"""
|
|
55
56
|
D-Match for hyper simulation
|
|
@@ -62,13 +63,16 @@ class DMatch:
|
|
|
62
63
|
For a sematic cluster pair by `id`, we set map[(id, id)] = R as the relation, where (u_id, v_id) in R, are node's id.
|
|
63
64
|
"""
|
|
64
65
|
|
|
65
|
-
class Delta:
|
|
66
|
+
class Delta: # Delta(u, v)
|
|
66
67
|
def __init__(self) -> None: ...
|
|
67
68
|
def add_sematic_cluster_pair(self, u: Node, v: Node, cluster_u: list[Hyperedge], cluster_v: list[Hyperedge]) -> int: ...
|
|
68
69
|
"""
|
|
69
70
|
Add a sematic of (u, v), register a id of the pair that, (cluster_u, id) and (cluster_v, id)
|
|
70
71
|
"""
|
|
71
72
|
|
|
73
|
+
# (u, v) (cluster_u, cluster_v)
|
|
74
|
+
# (u', v')
|
|
75
|
+
|
|
72
76
|
class Hypergraph:
|
|
73
77
|
"""
|
|
74
78
|
Hypergraph class.
|
|
@@ -11,6 +11,9 @@ fn simulation(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
11
11
|
m.add_class::<graph::hypergraph::Node>()?;
|
|
12
12
|
m.add_class::<graph::hypergraph::Hyperedge>()?;
|
|
13
13
|
m.add_class::<graph::hypergraph::LMatchImpl>()?;
|
|
14
|
+
m.add_class::<graph::hypergraph::DeltaPy>()?;
|
|
15
|
+
m.add_class::<graph::hypergraph::DMatchImpl>()?;
|
|
16
|
+
|
|
14
17
|
m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter, m)?)?;
|
|
15
18
|
m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter_fn, m)?)?;
|
|
16
19
|
m.add_function(wrap_pyfunction!(graph::networkx_graph::is_simulation_isomorphic, m)?)?;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import simulation
|
|
2
|
+
|
|
3
|
+
from simulation import *
|
|
4
|
+
query = Hypergraph()
|
|
5
|
+
query.add_node("a") # id 0
|
|
6
|
+
query.add_node("b") # id 1
|
|
7
|
+
query.add_node("c") # id 2
|
|
8
|
+
query.add_hyperedge(Hyperedge({0, 1}, "e1", 0))
|
|
9
|
+
query.add_hyperedge(Hyperedge({1, 2}, "e2", 1))
|
|
10
|
+
query.add_hyperedge(Hyperedge({0, 2}, "e3", 2))
|
|
11
|
+
|
|
12
|
+
data = Hypergraph()
|
|
13
|
+
data.add_node("a")
|
|
14
|
+
data.add_node("b")
|
|
15
|
+
data.add_node("c")
|
|
16
|
+
data.add_hyperedge(Hyperedge({0, 1}, "e1", 0))
|
|
17
|
+
data.add_hyperedge(Hyperedge({1, 2}, "e2", 1))
|
|
18
|
+
data.add_hyperedge(Hyperedge({0, 2}, "e3", 2))
|
|
19
|
+
|
|
20
|
+
# register type_same
|
|
21
|
+
|
|
22
|
+
query_vertices = []
|
|
23
|
+
data_vertices = []
|
|
24
|
+
|
|
25
|
+
m1= {}
|
|
26
|
+
|
|
27
|
+
for u in query_vertices:
|
|
28
|
+
for v in data_vertices:
|
|
29
|
+
# nli,
|
|
30
|
+
m1[u, v] = True
|
|
31
|
+
|
|
32
|
+
query.set_type_same_fn(lambda x_id, y_id: m1[x_id, y_id])
|
|
33
|
+
|
|
34
|
+
delta = Delta()
|
|
35
|
+
|
|
36
|
+
likely_vertices = []
|
|
37
|
+
m2 = {}
|
|
38
|
+
|
|
39
|
+
for (u, v) in likely_vertices:
|
|
40
|
+
pairs = []
|
|
41
|
+
for pair in pairs:
|
|
42
|
+
delta.add_sematic_cluster_pair(u, v, pair[0], pair[1])
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
matches = {}
|
|
48
|
+
for (u, v), pair in m2.items():
|
|
49
|
+
matches[u, v] = [(1, 2)]
|
|
50
|
+
|
|
51
|
+
d_match = DMatch.from_dict(matches)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
sim = Hypergraph.get_hyper_simulation(query, data, delta, d_match)
|
|
56
|
+
|
|
57
|
+
# set[tuple[int, int]]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|