Skip to content

eles.hierholzer(rootOrOptions?, directed?)

eles.hierholzer — Collection > Algorithms > Connectivity and Eulerian paths. Cytoscape.js signatures, parameters and return contract.

eles.hierholzer — Collection › Algorithms › Connectivity and Eulerian paths

Preview · Collection › Algorithms › Connectivity and Eulerian paths

Read in the complete API reference · All API members

// Find an Eulerian trail or circuit over this collection's edges
eles.hierholzer(rootOrOptions?: HierholzerOptions | Collection<any, any, any> | undefined, directed?: boolean | undefined): HierholzerResult

Find an Eulerian trail or circuit over this collection's edges. The directed mode checks directed degree balance; the default treats edges as undirected. A requested root must be a valid starting node for the trail.

Parameters
NameDescription
rootOrOptions: HierholzerOptions | Collection<any, any, any> | undefined?

Starting node or an options object; omit to choose an eligible node.

directed: boolean | undefined?

True to follow outgoing edges only; defaults to false.

Returns HierholzerResult

{ found, trail }; trail is undefined when no trail exists. Collections are sets, so a node visited more than once appears only once in the trail collection.

Example

const result = eles.hierholzer({ root: cy.getElementById('a'), directed: false });
console.log(result.found); // true

Example graph and handle setup

Throws

if a supplied root is a selector string