Trait transit_grid::graphs::TopologyGraphRepairer
source · pub trait TopologyGraphRepairer {
// Required methods
fn repair_edge(&mut self, node1: NodeId, node2: NodeId);
fn reverse_dual_edge(&mut self, node1: NodeId, node2: NodeId);
fn cross_link_dual_edge(&mut self, node1: NodeId, node2: NodeId);
}
Expand description
TopologyGraphRepairer
provides functionality to manipulate and repair edges in a topological graph.
It provides methods for reversing dual edges and cross-linking dual edges.
Required Methods§
sourcefn repair_edge(&mut self, node1: NodeId, node2: NodeId)
fn repair_edge(&mut self, node1: NodeId, node2: NodeId)
Repairs the direction of edges in a graph if they are incorrectly directed.
This function repairs edges between two nodes in the graph by examining their direction.
If the edges have the same direction (either both outgoing or both incoming), the direction
of the edges will be switched to ensure a consistent direction from node1
to node2
.
Examples
Correct scenarios: a -> node1_indices.0 -> node2_indices.0 -> b a -> node1_indices.0 -> node2_indices.1 -> b a -> node1_indices.1 -> node2_indices.0 -> b
Incorrect scenarios: a -> node1_indices.0 <- node2_indices.0 -> b a -> node1_indices.1 <- node2_indices.0 -> b a -> node1_indices.0 <- node2_indices.1 -> b
In the incorrect scenarios, the function will correct the edge directions as: a -> node1_indices.0 -> node2_indices.0 -> b a -> node1_indices.1 -> node2_indices.0 -> b a -> node1_indices.0 -> node2_indices.1 -> b
Arguments
node1
: The first node of the edge pair.node2
: The second node of the edge pair.
Panics
This function will panic if either of the node indices is not present in the graph.
Note
This function is mainly intended to be used for directed graphs. Using it for undirected graphs may not have the intended effect.
This function should be used when a graph’s edge directions are set manually and may be incorrect, and when it’s important that the edges have a specific direction for the logic of the application.
sourcefn reverse_dual_edge(&mut self, node1: NodeId, node2: NodeId)
fn reverse_dual_edge(&mut self, node1: NodeId, node2: NodeId)
Reverse the dual edge defined by the two given node IDs.
Implementations should ensure that after this operation, the direction of the dual edge between the two nodes is reversed. This implies that if the edge was directed from node1
to node2
, it should be directed from node2
to node1
after this operation, and vice versa.
Arguments
node1
- The ID of the first node defining the dual edge to be reversed.node2
- The ID of the second node defining the dual edge to be reversed.
sourcefn cross_link_dual_edge(&mut self, node1: NodeId, node2: NodeId)
fn cross_link_dual_edge(&mut self, node1: NodeId, node2: NodeId)
Cross-link the dual edge defined by the two given node IDs.
Implementations should ensure that after this operation, the dual edge between the two nodes is cross-linked. This implies that if there was a direct edge from node1
to node2
, there should now also be a direct edge from node2
to node1
after this operation, and vice versa.
Arguments
node1
- The ID of the first node defining the dual edge to be cross-linked.node2
- The ID of the second node defining the dual edge to be cross-linked.