optrees (version 1.0)

getMinimumArborescence: Computes a minimum cost arborescence

Description

Given a connected weighted directed graph, getMinimumArborescence computes a minimum cost arborescence. This function provides a method to find the minimum cost arborescence with Edmonds' algorithm.

Usage

getMinimumArborescence(nodes, arcs, source.node = 1, algorithm = "Edmonds", stages.data = FALSE, show.data = TRUE, show.graph = TRUE, check.graph = FALSE)

Arguments

nodes
vector containing the nodes of the graph, identified by a number that goes from $1$ to the order of the graph.
arcs
matrix with the list of arcs of the graph. Each row represents one arc. The first two columns contain the two endpoints of each arc and the third column contains their weights.
source.node
number pointing to the source node of the graph. It's node $1$ by default.
algorithm
denotes the algorithm used to find a minimum cost arborescence: "Edmonds".
check.graph
logical value indicating if it is necesary to check the graph. Is FALSE by default.
show.data
logical value indicating if the function displays the console output (TRUE) or not (FALSE). The default is TRUE.
show.graph
logical value indicating if the function displays a graphical representation of the graph and its minimum arborescence (TRUE) or not (FALSE). The default is TRUE.
stages.data
logical value indicating if the function returns data of each stage. The default is FALSE.

Value

getMinimumArborescence returns a list with:
tree.nodes
vector containing the nodes of the minimum cost arborescence.
tree.arcs
matrix containing the list of arcs of the minimum cost arborescence.
weight
value with the sum of weights of the arcs.
stages
number of stages required.
time
time needed to find the minimum cost arborescence.
This function also represents the graph and the minimum arborescence and prints to the console the results with additional information (number of stages, computational time, etc.).

Details

Given a connected weighted directed graph, a minimum cost arborescence is an arborescence such that the sum of the weight of its arcs is minimum. In some cases, it is possible to find several minimum cost arborescences, but the proposed algorithm only finds one of them.

Edmonds' algorithm was developed by the mathematician and computer scientist Jack R. Edmonds in 1967. Although, it was previously proposed in 1965 by Yoeng-jin Chu and Tseng-hong Liu. This algorithm decreases the weights of the arcs in a graph and compacts cycles of zero weight until it can find an arborescence. This arborescence has to be a minimum cost arborescence of the graph.

References

Chu, Y. J., and Liu, T. H., "On the Shortest Arborescence of a Directed Graph", Science Sinica, vol. 14, 1965, pp. 1396-1400.

Edmonds, J., "Optimum Branchings", Journal of Research of the National Bureau of Standards, vol. 71B, No. 4, October-December 1967, pp. 233-240.

Examples

Run this code
# Graph
nodes <- 1:4
arcs <- matrix(c(1,2,2, 1,3,3, 1,4,4, 2,3,3, 2,4,4, 3,2,3,
                 3,4,1, 4,2,1, 4,3,2),byrow = TRUE, ncol = 3)
# Minimum cost arborescence
getMinimumArborescence(nodes, arcs)

Run the code above in your browser using DataLab