Module-level Functions
All 12 module-level convenience functions available after from qnet_core import ....
Topology & File Functions
from_qnet_file(filepath)
Load a .qnet file and return an initialized engine.
from_qnet_file(filepath: str) -> QNetEngine
| Parameter | Type | Description |
|---|---|---|
filepath | str | Path to .qnet JSON file |
Returns: QNetEngine — initialized engine with loaded topology
generate_topology(name)
Generate a pre-built topology by name.
generate_topology(name: str) -> NetworkTopologyPayload
| Parameter | Type | Description |
|---|---|---|
name | str | Topology name: "telecom_backbone", "repeater_chain", or "hybrid_satellite_fiber" |
Returns: NetworkTopologyPayload with .nodes and .links
compare_topologies(endpoints, fidelity_target, max_latency_ms, runs, strategy)
Run Monte Carlo on each topology and pick the best by success rate.
compare_topologies(
endpoints: List[TopologyEndpoints],
fidelity_target: float,
max_latency_ms: float,
runs: int,
strategy: Optional[StrategyType] = None,
) -> TopologyComparisonReport
| Parameter | Type | Default | Description |
|---|---|---|---|
endpoints | List[TopologyEndpoints] | — | Topology-to-node mappings |
fidelity_target | float | — | Required entanglement fidelity |
max_latency_ms | float | — | Maximum allowed latency (ms) |
runs | int | — | Number of Monte Carlo runs per topology |
strategy | StrategyType | None | Routing strategy |
Returns: TopologyComparisonReport
save_topology(engine, filepath)
Persist engine's current topology to a .qnet file.
save_topology(engine: QNetEngine, filepath: str) -> None
| Parameter | Type | Description |
|---|---|---|
engine | QNetEngine | Engine with topology to save |
filepath | str | Output .qnet file path |
Returns: None
load_topology(engine, filepath)
Load a .qnet file into an existing engine.
load_topology(engine: QNetEngine, filepath: str) -> None
| Parameter | Type | Description |
|---|---|---|
engine | QNetEngine | Engine to load topology into |
filepath | str | Input .qnet file path |
Returns: None
validate(filepath)
Validate a .qnet file — returns a dict, never raises.
validate(filepath: str) -> dict
| Parameter | Type | Description |
|---|---|---|
filepath | str | Path to .qnet JSON file |
Returns: dict with keys: valid (bool), filepath (str), errors (list), warnings (list)
load_qnet_file(filepath)
Load and parse a .qnet JSON file as structured Python objects.
load_qnet_file(filepath: str) -> QNetFile
| Parameter | Type | Description |
|---|---|---|
filepath | str | Path to .qnet JSON file |
Returns: QNetFile
diff(file1, file2)
Diff two .qnet files on disk.
diff(file1: str, file2: str) -> dict
| Parameter | Type | Description |
|---|---|---|
file1 | str | Path to first .qnet file |
file2 | str | Path to second .qnet file |
Returns: dict with keys: summary, nodes_added, nodes_removed, nodes_modified, links_added, links_removed, links_modified; or {"error": ...} on failure
diff_topologies(snap1, snap2)
Diff two topology snapshots programmatically.
diff_topologies(snap1: TopologySnapshot, snap2: TopologySnapshot) -> TopologyDiff
| Parameter | Type | Description |
|---|---|---|
snap1 | TopologySnapshot | First snapshot |
snap2 | TopologySnapshot | Second snapshot |
Returns: TopologyDiff
Protocol Convenience Functions
qkd(engine, from_node, to_node, fidelity_target, max_latency_ms, rounds?, error_rate_tolerance?)
Run BB84-style QKD (convenience wrapper).
qkd(
engine: QNetEngine,
from_node: str,
to_node: str,
fidelity_target: float,
max_latency_ms: float,
rounds: int = 100,
error_rate_tolerance: float = 0.11,
) -> QKDResult
| Parameter | Type | Default | Description |
|---|---|---|---|
engine | QNetEngine | — | Simulation engine |
from_node | str | — | Source node ID |
to_node | str | — | Destination node ID |
fidelity_target | float | — | Required entanglement fidelity |
max_latency_ms | float | — | Maximum allowed latency (ms) |
rounds | int | 100 | Number of QKD rounds |
error_rate_tolerance | float | 0.11 | BB84 error threshold |
Returns: QKDResult
teleportation(engine, source_node, target_node, state_fidelity?, classical_bandwidth_ms?)
Execute teleportation (convenience wrapper).
teleportation(
engine: QNetEngine,
source_node: str,
target_node: str,
state_fidelity: float = 0.95,
classical_bandwidth_ms: float = 100.0,
) -> TeleportationOutcome
| Parameter | Type | Default | Description |
|---|---|---|---|
engine | QNetEngine | — | Simulation engine |
source_node | str | — | Source node (Alice) |
target_node | str | — | Target node (Bob) |
state_fidelity | float | 0.95 | Input state fidelity |
classical_bandwidth_ms | float | 100.0 | Classical channel latency (ms) |
Returns: TeleportationOutcome
distributed_computation(engine, participants, coordination_topology, measurement_basis, classical_relay_latency_ms?)
Run distributed quantum computation (convenience wrapper).
distributed_computation(
engine: QNetEngine,
participants: List[str],
coordination_topology: CoordinationTopology,
measurement_basis: MeasurementBasis,
classical_relay_latency_ms: float = 5.0,
) -> DistributedComputingResult
| Parameter | Type | Default | Description |
|---|---|---|---|
engine | QNetEngine | — | Simulation engine |
participants | List[str] | — | Participant node IDs |
coordination_topology | CoordinationTopology | — | Coordination pattern |
measurement_basis | MeasurementBasis | GHZ, 0.85 | Measurement basis config |
classical_relay_latency_ms | float | 5.0 | Classical relay latency (ms) |
Returns: DistributedComputingResult