Graph traversal
Shortest path
MolecularGraph.Graph.diameter
— Methoddiameter(graph::AbstractGraph) -> Int
Compute the diameter of the graph (the largest eccentricity of any nodes).
MolecularGraph.Graph.distance
— Methoddistance(graph::AbstractGraph, source::Int, target::Int) -> Int
reversedistance(graph::DirectedGraph, source::Int, target::Int) -> Int
Compute the distance (shortest path length) from source
to target
. If the nodes are not reachable each other, the value will be nothing
.
MolecularGraph.Graph.distancematrix
— Methoddistancematrix(graph::OrderedGraph) -> Matrix{Float64}
Generate the distance matrix of the graph.
Note that the type of the generated matrix will be Float64
. If the nodes are not reachable each other, the distance value will be Inf
.
MolecularGraph.Graph.eccentricity
— Methodeccentricity(graph::UndirectedGraph, v::Int) -> Int
Compute the eccentricity of the graph (the largest distance between v
and any other nodes).
MolecularGraph.Graph.isreachable
— Methodreachablenodes(graph::AbstractGraph, u::Int, v::Int) -> Bool
reversereachablenodes(graph::DirectedGraph, u::Int, v::Int) -> Bool
Return whether the node v
is reachable from u
.
MolecularGraph.Graph.longestshortestpathnodes
— Methodlongestshortestpathnodes(graph::UndirectedGraph) -> Vector{Int}
Compute the longest shortest path in the graph (a path between two arbitrary peripheral nodes) as a vector of nodes that starts with one of the peripheral node and ends with the other side.
MolecularGraph.Graph.reachablenodes
— Methodreachablenodes(graph::AbstractGraph, node::Int) -> Set{Int}
reversereachablenodes(graph::DirectedGraph, node::Int) -> Set{Int}
Return the set of reachable nodes from node
.
MolecularGraph.Graph.shortestpathedges
— Methodshortestpathedges(graph::UndirectedGraph, u::Int, v::Int) -> Vector{Int}
Compute the shortest path between u
and v
as a vector of the edges that forms the path. Return nothing if not reachable.
MolecularGraph.Graph.shortestpathnodes
— Methodshortestpathnodes(graph::UndirectedGraph, u::Int, v::Int) -> Vector{Int}
Compute the shortest path between u
and v
as a vector of the nodes that forms the path. Return nothing if not reachable.