Fleury Eulerian
fleuryEulerian(graph) returns a path that uses every edge exactly once, choosing non-bridges while alternatives exist. It accepts an undirected adjacency list or Graph<N, W> and returns absence when no Eulerian path exists.
| Signature | Returns | Complexity |
|---|---|---|
fleuryEulerian(graph: usize[][]) | usize[]? | O(E(V + E)) |
fleuryEulerian(graph: Graph<N, W>) | usize[]? | O(E(V + E)) |
The adjacency list represents an undirected graph with symmetric entries. A successful path has E + 1 vertices.
Example
tyrus
import { fleuryEulerian } from "tyrus:algorithm";
const path: usize[]? = fleuryEulerian([[1, 2], [0, 2], [0, 1]]);
if (path) {
print(path.length); // 4
}Study result
fleuryEulerianInfo returns the path together with edge examination and bridge-choice metrics. Import both the base and specialized interfaces explicitly.
tyrus
interface FleuryEulerianInfo {
path: usize[]?;
usedEdgeCount: usize;
examinedEdgeCount: usize;
isCircuit: bool;
bridgeCheckCount: usize;
avoidedBridgeChoiceCount: usize;
}tyrus
import { EulerianInfo, FleuryEulerianInfo, fleuryEulerianInfo } from "tyrus:algorithm";
const graph: usize[][] = [[3, 1, 2], [0, 2], [1, 0], [0]];
const info: FleuryEulerianInfo = fleuryEulerianInfo(graph);
print(info.path ?? []); // [0, 1, 2, 0, 3]
print(info.usedEdgeCount); // 4
print(info.examinedEdgeCount); // 5
print(info.isCircuit); // false
print(info.bridgeCheckCount); // 2
print(info.avoidedBridgeChoiceCount); // 1