pub struct ConnectionGraph { /* private fields */ }Expand description
An undirected port connection graph.
Built once and queried many times: a traversal that re-scanned the model for each step would be quadratic on files with thousands of ports.
Implementations§
Source§impl ConnectionGraph
impl ConnectionGraph
Sourcepub fn build(model: &Model) -> (Self, Vec<SystemAnomaly>)
pub fn build(model: &Model) -> (Self, Vec<SystemAnomaly>)
Read every IfcRelConnectsPorts in the file.
A connection naming a non-port, or an entity not in the file, is reported and skipped: one malformed relationship must not cost the caller the rest of the network.
Port ancestry is read against the release the model declares.
Sourcepub fn connections(&self) -> &[Connection]
pub fn connections(&self) -> &[Connection]
Every stated connection, in file order.
Sourcepub fn neighbours(&self, port: EntityId) -> Vec<EntityId>
pub fn neighbours(&self, port: EntityId) -> Vec<EntityId>
Ports directly connected to port, ascending by id.
Sourcepub fn reachable_from(&self, start: EntityId) -> Vec<EntityId>
pub fn reachable_from(&self, start: EntityId) -> Vec<EntityId>
Every port reachable from start, including start itself.
Breadth-first with a visited set, so a network containing a LOOP – a ring main, a recirculating circuit – terminates instead of running forever. Loops are normal in real distribution systems, not corrupt data, so this must not be a refusal.
Sourcepub fn components(&self) -> Vec<Vec<EntityId>>
pub fn components(&self) -> Vec<Vec<EntityId>>
Connected components of the graph, each sorted, components ascending.
A distribution system that splits into two components is usually an authoring error – a missing connection – and is worth surfacing.