458458"""
459459 getconnectingedge(node1::Node, node2::Node)
460460
461- Edge shared by (or connecting) `node1` and `node2`, that is: edge incident
462- to both nodes. An error is thrown if the 2 nodes are not connected .
461+ Edge shared by (or connecting) `node1` and `node2`, that is, edge incident
462+ to both nodes; or `nothing` if the nodes are not adjacent (without error) .
463463
464464See also [`isconnected`](@ref)
465465"""
@@ -469,15 +469,36 @@ function getconnectingedge(node1::Node, node2::Node)
469469 e1 === e2 && return e1
470470 end
471471 end
472- error (" nodes not connected" )
472+ return nothing
473+ end
474+ """
475+ getconnectingedge(n1_number::Int, n2_number::Int, net::HybridNetwork)
476+
477+ Edge in `net` that is incident to nodes `n1` and `n2` of specified numbers;
478+ or `nothing` if `n1` and `n2` are not adjacent and no such edge exists
479+ (without any error).
480+
481+ Warning: if `net` has parallel edges, there might 2+ (hybrid and partner)
482+ edges connecting `n1` and `n2`. One of them is returned, arbitrarily.
483+ """
484+ function getconnectingedge (n1num:: Int , n2num:: Int , net:: HybridNetwork )
485+ n1i = findfirst (n -> n. number == n1num, net. node)
486+ isnothing (n1i) && error (" no node numbered $n1num " )
487+ n1 = net. node[n1i]
488+ for e in n1. edge
489+ n2 = getOtherNode (e,n1)
490+ if n2. number == n2num
491+ return e
492+ end
493+ end
473494 return nothing
474495end
475496
476497"""
477- isconnected(node1 ::Node, node2 ::Node)
498+ isconnected(n1 ::Node, n2 ::Node)
478499
479- Check if two nodes are connected by an edge. Return true if connected, false
480- if not connected .
500+ `true` if nodes `n1` and `n2` are adjacent, that is, connected by an edge;
501+ `false` otherwise .
481502
482503See also [`getconnectingedge`](@ref)
483504"""
0 commit comments