etour {PairViz}R Documentation

Constructs eulerian tours on a graph.

Description

etour– Constructs a closed eulerian tour on a graph using Hierholzer's algorithm. Returns a vector of node labels. If weighted is TRUE constructs a weight-decreasing eulerian using the modified Hierholzer's algorithm. Usually etour is not called directly, rather the generic function eulerian is used.

Usage

etour(g, start=NULL,weighted=TRUE)

Arguments

g a graph satisfying is_even_graph
start an optional starting node for the tour.
weighted whether tour uses weights

Details

The supplied graph should satisfyis_even_graph. If weighted is TRUE the lowest weight edge is found, and the tour starts at the one of its nodes, picking the node with the bigger second-smallest edge weight. After that the tour follows weight-increasing edges. If weighted is FALSE weights are ignored.

Author(s)

C.B. Hurley and R.W. Oldford

References

see overview

Examples

require(PairViz)

g <- mk_even_graph(5)

etour(g)
g <- mk_even_graph(6) # adds 3 extra edges to g, so all nodes are even
etour(g)
etour(g, start= "4") # modifies the starting node

# On a general graph.
v <- LETTERS[1:4]
g <- new("graphNEL",nodes=v)
g <- addEdge(v[1],v[3:4],g,1:2)
g <- addEdge(v[2],v[3:4],g,3:4)
etour(g) 

eulerian(g) # The eulerian wrapper looks after this

n <- LETTERS[1:5]
g <- new("graphNEL",nodes=n)
g <- addEdge(n[1],n[2:3],g)
g <-addEdge(n[2],n[3:5],g)
g <-addEdge(n[4],n[3],g)
is_even_graph(g)
etour(mk_even_graph(g))


[Package PairViz version 1.0 Index]