Skip to main content

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
ParameterTypeDescription
filepathstrPath 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
ParameterTypeDescription
namestrTopology 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
ParameterTypeDefaultDescription
endpointsList[TopologyEndpoints]Topology-to-node mappings
fidelity_targetfloatRequired entanglement fidelity
max_latency_msfloatMaximum allowed latency (ms)
runsintNumber of Monte Carlo runs per topology
strategyStrategyTypeNoneRouting strategy

Returns: TopologyComparisonReport

save_topology(engine, filepath)

Persist engine's current topology to a .qnet file.

save_topology(engine: QNetEngine, filepath: str) -> None
ParameterTypeDescription
engineQNetEngineEngine with topology to save
filepathstrOutput .qnet file path

Returns: None

load_topology(engine, filepath)

Load a .qnet file into an existing engine.

load_topology(engine: QNetEngine, filepath: str) -> None
ParameterTypeDescription
engineQNetEngineEngine to load topology into
filepathstrInput .qnet file path

Returns: None

validate(filepath)

Validate a .qnet file — returns a dict, never raises.

validate(filepath: str) -> dict
ParameterTypeDescription
filepathstrPath 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
ParameterTypeDescription
filepathstrPath to .qnet JSON file

Returns: QNetFile

diff(file1, file2)

Diff two .qnet files on disk.

diff(file1: str, file2: str) -> dict
ParameterTypeDescription
file1strPath to first .qnet file
file2strPath 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
ParameterTypeDescription
snap1TopologySnapshotFirst snapshot
snap2TopologySnapshotSecond 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
ParameterTypeDefaultDescription
engineQNetEngineSimulation engine
from_nodestrSource node ID
to_nodestrDestination node ID
fidelity_targetfloatRequired entanglement fidelity
max_latency_msfloatMaximum allowed latency (ms)
roundsint100Number of QKD rounds
error_rate_tolerancefloat0.11BB84 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
ParameterTypeDefaultDescription
engineQNetEngineSimulation engine
source_nodestrSource node (Alice)
target_nodestrTarget node (Bob)
state_fidelityfloat0.95Input state fidelity
classical_bandwidth_msfloat100.0Classical 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
ParameterTypeDefaultDescription
engineQNetEngineSimulation engine
participantsList[str]Participant node IDs
coordination_topologyCoordinationTopologyCoordination pattern
measurement_basisMeasurementBasisGHZ, 0.85Measurement basis config
classical_relay_latency_msfloat5.0Classical relay latency (ms)

Returns: DistributedComputingResult