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.
@@ -543,7 +543,7 @@ dependencies = [
543
543
 
544
544
  [[package]]
545
545
  name = "simulation"
546
- version = "0.1.7"
546
+ version = "0.1.8"
547
547
  dependencies = [
548
548
  "graph-base",
549
549
  "graph-simulation",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "simulation"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  edition = "2021"
5
5
  license = "MIT"
6
6
  description = "A Python package for simulation algorithms"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simulation-alg
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "simulation-alg"
7
- version = "0.1.7"
7
+ version = "0.1.8"
8
8
  requires-python = ">=3.10"
9
9
  classifiers = [
10
10
  "Programming Language :: Rust",
@@ -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