1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Neuro-symbolic module: physics-informed entity scoring for knowledge graphs.
//!
//! This module blends **GNN cosine similarity** (neural signal) with **analytical
//! physics plausibility** (symbolic signal) to produce a combined entity score that
//! is both embedding-aware and physically grounded.
//!
//! # Architecture
//!
//! ```text
//! KgGraph ──► GraphSageEncoder ──► EntityEmbeddings
//! │
//! query_embedding ──────────────────┐ │ cosine sim → neural_score
//! └──────┤
//! KgEntity.properties ──► PhysicsContext ──┤
//! (Fo / Re / ε / V) └──► physics_score
//! │
//! combined = (1-λ)·neural + λ·physics ◄┘
//! ```
//!
//! # Quick start
//!
//! ```rust
//! use std::sync::Arc;
//! use std::collections::HashMap;
//! use oxirs_graphrag::gnn_encoder::{GraphSageConfig, GraphSageEncoder, KgGraph};
//! use oxirs_graphrag::neuro_symbolic::{
//! PhysicsDomain, PhysicsContext,
//! KgEntity, PinnEntityScorer,
//! };
//! use scirs2_core::ndarray_ext::{Array1, Array2};
//!
//! let config = GraphSageConfig {
//! input_dim: 4, hidden_dim: 4, output_dim: 4,
//! num_layers: 2, dropout: 0.0, k_neighbors: 2, learning_rate: 0.0,
//! };
//! let encoder = Arc::new(GraphSageEncoder::new(&config).expect("encoder"));
//! let ctx = PhysicsContext::new(PhysicsDomain::ThermalDiffusion {
//! thermal_diffusivity: 1e-5,
//! });
//! let scorer = PinnEntityScorer::new(Arc::clone(&encoder), ctx, 0.3);
//!
//! let kg = KgGraph {
//! num_nodes: 2,
//! edges: vec![(0, 1)],
//! node_features: Array2::zeros((2, 4)),
//! };
//! let entities = vec![
//! KgEntity { id: "e0".into(), embedding_idx: 0, properties: HashMap::new() },
//! KgEntity { id: "e1".into(), embedding_idx: 1, properties: HashMap::new() },
//! ];
//! let query = Array1::zeros(4);
//! let ranked = scorer.rank(&kg, &entities, &query).expect("rank");
//! assert_eq!(ranked.len(), 2);
//! ```
pub use ;
pub use ;
pub use ;