Learn R Programming

eulerian (version 1.0)

hasEulerianCycle: Method for checking whether an eulerian cycle exists.

Description

An eulerian cycle is a path in a graph which visits every edge exactly once, and starts and ends at the same node.

Usage

hasEulerianCycle(graph)

Arguments

graph
a graphNEL object.

Value

TRUE, if graph has an auler cycle. FALSE, otherwise.

Details

A graph will have an euler cycle if and only if every node has same number of edges entering into and going out of it.

Examples

Run this code
	require(graph)
	require(eulerian)
	g <- new("graphNEL", nodes=LETTERS[1:4], edgemode="directed")
	g <- addEdge(graph=g, from=LETTERS[1:4], to=LETTERS[c(2:4,1)])
	hasEulerianCycle(g)

Run the code above in your browser using DataLab