Skip to main content

Crate sheaf_coherence

Crate sheaf_coherence 

Source
Expand description

§sheaf-coherence

Cellular sheaf coherence for multi-agent belief alignment.

A cellular sheaf assigns vector spaces (stalks) to nodes and linear maps (restriction maps) to edges of a graph. The sheaf Laplacian L_F measures how much a section (belief assignment) disagrees across edges:

  • L_F x = 0global section (perfect agreement)
  • ||L_F x|| / ||x||disagreement level
  • 1 - ||L_F x|| / ||x||alignment score

§Quick Start

use sheaf_coherence::{CellularSheaf, SheafLaplacian, CoherenceMeasure, AgentSheaf, AgentBelief};

// Build a complete sheaf on 3 nodes with 2D stalks
let sheaf = CellularSheaf::complete(3, 2).unwrap();
let lap = SheafLaplacian::from_sheaf(&sheaf).unwrap();

// Perfect agreement → alignment = 1.0
let beliefs = vec![1.0, 0.0, 1.0, 0.0, 1.0, 0.0];
let coherence = CoherenceMeasure::from_flat(&sheaf, &beliefs, 100, 1e-10).unwrap();
assert!(coherence.alignment > 0.99);

// Agent-based interface
let agents = vec![
    AgentBelief::new("alice", vec![1.0, 0.0], 0.9),
    AgentBelief::new("bob",   vec![1.0, 0.0], 0.8),
    AgentBelief::new("carol", vec![0.0, 1.0], 0.7),
];
let asheaf = AgentSheaf::complete(agents).unwrap();
let coh = asheaf.coherence(100, 1e-10).unwrap();

Re-exports§

pub use agent::AgentBelief;
pub use agent::AgentSheaf;
pub use coherence::CoherenceMeasure;
pub use error::SheafError;
pub use laplacian::SheafLaplacian;
pub use section::GlobalSection;
pub use sheaf::CellularSheaf;
pub use sheaf::SheafBuilder;

Modules§

agent
coherence
error
laplacian
section
sheaf