simulation-alg 0.1.8__tar.gz → 0.1.9__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.8 → simulation_alg-0.1.9}/Cargo.lock +4 -4
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/Cargo.toml +1 -1
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/PKG-INFO +1 -1
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/pyproject.toml +1 -1
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/simulation.pyi +15 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/hypergraph.rs +47 -5
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/lib.rs +1 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.github/workflows/ci.yml +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.gitignore +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.gitmodules +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/LICENSE +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/README.md +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/hyper-simulation.log +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/python/__init__.py +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/requirements.txt +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/mod.rs +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/networkx_graph.rs +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/utils.rs +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/test.py +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/tests/test_hyper_simulation.py +0 -0
- {simulation_alg-0.1.8 → simulation_alg-0.1.9}/tests/test_simulation.py +0 -0
|
@@ -177,9 +177,9 @@ dependencies = [
|
|
|
177
177
|
|
|
178
178
|
[[package]]
|
|
179
179
|
name = "graph-base"
|
|
180
|
-
version = "0.1.
|
|
180
|
+
version = "0.1.14"
|
|
181
181
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
182
|
-
checksum = "
|
|
182
|
+
checksum = "1c337eeba84f9bf9bd65f89631119a34215bf46251e751abc1a6819195d71287"
|
|
183
183
|
dependencies = [
|
|
184
184
|
"lazy_static",
|
|
185
185
|
"rand",
|
|
@@ -188,9 +188,9 @@ dependencies = [
|
|
|
188
188
|
|
|
189
189
|
[[package]]
|
|
190
190
|
name = "graph-simulation"
|
|
191
|
-
version = "0.1.
|
|
191
|
+
version = "0.1.24"
|
|
192
192
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
193
|
-
checksum = "
|
|
193
|
+
checksum = "3744a0d1d724cad58fef5eee7383bcdc3cd318952f4611ca9f3916fe0bf01e46"
|
|
194
194
|
dependencies = [
|
|
195
195
|
"bincode",
|
|
196
196
|
"env_logger",
|
|
@@ -49,6 +49,15 @@ class Hyperedge:
|
|
|
49
49
|
def id_set(self) -> set[int]: ...
|
|
50
50
|
def desc(self) -> str: ...
|
|
51
51
|
|
|
52
|
+
class Event:
|
|
53
|
+
"""
|
|
54
|
+
Event class.
|
|
55
|
+
"""
|
|
56
|
+
phrase: str
|
|
57
|
+
sc_id: int
|
|
58
|
+
binary_relation: set[tuple[int, int]]
|
|
59
|
+
|
|
60
|
+
def __init__(self, phrase: str, sc_id: int, binary_relation: set[tuple[int, int]]): ...
|
|
52
61
|
|
|
53
62
|
# (cluster_u, cluster_v)
|
|
54
63
|
class DMatch:
|
|
@@ -92,6 +101,11 @@ class Hypergraph:
|
|
|
92
101
|
|
|
93
102
|
def get_node_desc_by_id(self, node_id: int) -> Optional[str]: ...
|
|
94
103
|
|
|
104
|
+
def get_hyper_simulation_trace(self) -> list[Event]:
|
|
105
|
+
"""
|
|
106
|
+
Get trace events of last time hyper simulation.
|
|
107
|
+
"""
|
|
108
|
+
|
|
95
109
|
@staticmethod
|
|
96
110
|
def hyper_simulation(query: 'Hypergraph', data: 'Hypergraph', l_match_fn: Callable[[Hyperedge, Hyperedge], dict[int, set[int]]]) -> dict[int, set[int]]:
|
|
97
111
|
"""
|
|
@@ -109,3 +123,4 @@ class Hypergraph:
|
|
|
109
123
|
"""
|
|
110
124
|
Hyper Simulation
|
|
111
125
|
"""
|
|
126
|
+
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
use std::{collections::{HashMap, HashSet}, fmt::Display, hash::Hash};
|
|
2
2
|
|
|
3
3
|
use pyo3::{prelude::*, types::PyList};
|
|
4
|
-
use graph_simulation::algorithm::hyper_simulation::{DMatch, Delta, HyperSimulation, LMatch, LPredicate, SematicCluster};
|
|
4
|
+
use graph_simulation::{algorithm::hyper_simulation::{DMatch, Delta, HSEvent, HyperSimulation, HyperSimulationTrace, LMatch, LPredicate, SematicCluster}, utils::logger::TraceLog};
|
|
5
5
|
use graph_base::interfaces::{edge, graph::{self, SingleId}, hypergraph::{self, ContainedHyperedge}, typed, vertex};
|
|
6
|
+
|
|
6
7
|
// use graph_base::interfaces::hypergraph;
|
|
7
8
|
|
|
8
9
|
#[derive(Clone, Debug, Eq)]
|
|
@@ -86,6 +87,25 @@ pub struct Hypergraph {
|
|
|
86
87
|
l_predicate_fn: Option<Py<PyAny>>, // (Hyperedge, Hyperedge) -> bool
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
#[pyclass(name = "Event")]
|
|
91
|
+
pub struct Event {
|
|
92
|
+
pub phrase: String,
|
|
93
|
+
pub sc_id: usize,
|
|
94
|
+
pub binary_relation: HashSet<(usize, usize)>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#[pymethods]
|
|
98
|
+
impl Event {
|
|
99
|
+
#[new]
|
|
100
|
+
pub fn new(phrase: String, sc_id: usize, binary_relation: HashSet<(usize, usize)>) -> Self {
|
|
101
|
+
Event {
|
|
102
|
+
phrase,
|
|
103
|
+
sc_id,
|
|
104
|
+
binary_relation,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
89
109
|
#[pymethods]
|
|
90
110
|
impl Hypergraph {
|
|
91
111
|
#[new]
|
|
@@ -153,6 +173,25 @@ impl Hypergraph {
|
|
|
153
173
|
.map(|(k, v)| (k.id(), v.into_iter().map(|n| n.id()).collect()))
|
|
154
174
|
.collect()
|
|
155
175
|
}
|
|
176
|
+
|
|
177
|
+
pub fn get_hyper_simulation_trace(&self) -> Vec<Event> {
|
|
178
|
+
let trace = HyperSimulationTrace::get_trace("hyper_simulation.trace").unwrap();
|
|
179
|
+
let events = trace.into_iter().map(|event| {
|
|
180
|
+
match event {
|
|
181
|
+
HSEvent::Base(sc_id, relation) => Event {
|
|
182
|
+
phrase: "base".to_string(),
|
|
183
|
+
sc_id,
|
|
184
|
+
binary_relation: relation
|
|
185
|
+
},
|
|
186
|
+
HSEvent::Derivation(sc_id, relation) => Event {
|
|
187
|
+
phrase: "derivation".to_string(),
|
|
188
|
+
sc_id,
|
|
189
|
+
binary_relation: relation
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}).collect();
|
|
193
|
+
events
|
|
194
|
+
}
|
|
156
195
|
}
|
|
157
196
|
|
|
158
197
|
impl Display for Node {
|
|
@@ -381,9 +420,8 @@ impl DMatchImpl {
|
|
|
381
420
|
}
|
|
382
421
|
}
|
|
383
422
|
|
|
384
|
-
// #[pyclass(name = "Delta")]
|
|
385
423
|
struct DeltaImpl<'a> {
|
|
386
|
-
sematic_cluster: HashMap<(&'a Node, &'a Node), Vec<(SematicCluster<'a, Hyperedge>, SematicCluster<'a, Hyperedge>)
|
|
424
|
+
sematic_cluster: HashMap<(&'a Node, &'a Node), Vec<(SematicCluster<'a, Hyperedge>, SematicCluster<'a, Hyperedge>)>>,
|
|
387
425
|
}
|
|
388
426
|
|
|
389
427
|
impl<'a> Delta<'a> for DeltaImpl<'a> {
|
|
@@ -414,12 +452,16 @@ impl<'a> DeltaImpl<'a> {
|
|
|
414
452
|
|
|
415
453
|
let sc_q = SematicCluster::new(q_id, q_edges);
|
|
416
454
|
let sc_d = SematicCluster::new(d_id, d_edges);
|
|
455
|
+
// Update sematic_cluster_cache
|
|
417
456
|
|
|
457
|
+
// sematic_cluster_cache.insert((&sc_q, &sc_d), q_id);
|
|
458
|
+
|
|
418
459
|
pair_map.entry((u, v)).or_default().push((sc_q, sc_d));
|
|
419
460
|
}
|
|
420
461
|
}
|
|
462
|
+
|
|
421
463
|
let res = DeltaImpl {
|
|
422
|
-
sematic_cluster: pair_map
|
|
464
|
+
sematic_cluster: pair_map,
|
|
423
465
|
};
|
|
424
466
|
|
|
425
467
|
return res;
|
|
@@ -431,7 +473,7 @@ impl<'a> DeltaImpl<'a> {
|
|
|
431
473
|
#[derive(Clone)]
|
|
432
474
|
#[pyclass(name = "Delta")]
|
|
433
475
|
pub struct DeltaPy {
|
|
434
|
-
sematic_cluster_cache: HashMap<(usize, usize), Vec<((Vec<usize>, usize), (Vec<usize>, usize))>>,
|
|
476
|
+
sematic_cluster_cache: HashMap<(usize, usize), Vec<((Vec<usize>, usize), (Vec<usize>, usize))>>, // (u_id, v_id) -> Vec<((q_edge_ids, sc_id), (d_edge_ids, sc_id))>
|
|
435
477
|
global_cnt: usize
|
|
436
478
|
}
|
|
437
479
|
|
|
@@ -13,6 +13,7 @@ fn simulation(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
13
13
|
m.add_class::<graph::hypergraph::LMatchImpl>()?;
|
|
14
14
|
m.add_class::<graph::hypergraph::DeltaPy>()?;
|
|
15
15
|
m.add_class::<graph::hypergraph::DMatchImpl>()?;
|
|
16
|
+
m.add_class::<graph::hypergraph::Event>()?;
|
|
16
17
|
|
|
17
18
|
m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter, m)?)?;
|
|
18
19
|
m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter_fn, m)?)?;
|
|
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
|