{"record":{"id":"826b15b7c2c84ef5","repo":"trekhleb/javascript-algorithms","slug":"eulerian-path-must-contain-two-odd-ranked-vertices","errorCode":null,"errorMessage":"Eulerian path must contain two odd-ranked vertices","messagePattern":"Eulerian path must contain two odd-ranked vertices","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/algorithms/graph/eulerian-path/eulerianPath.js","lineNumber":41,"sourceCode":"  const isCircuit = !Object.values(oddRankVertices).length;\n\n  if (!isCircuit && Object.values(oddRankVertices).length !== 2) {\n    throw new Error('Eulerian path must contain two odd-ranked vertices');\n  }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/graph/eulerian-path/eulerianPath.js#L23-L59","documentation":"Error \"Eulerian path must contain two odd-ranked vertices\" thrown in trekhleb/javascript-algorithms.","triggerScenarios":"eulerianPath is called on a graph that is not an Eulerian circuit and does not have exactly two odd-degree vertices (e.g. 1, 3, or 4 odd-ranked vertices), so no Eulerian path exists.","commonSituations":"Running Fleury's algorithm on a graph with 1, 3, or more odd-degree vertices; an Eulerian path requires exactly two odd-degree endpoints.","solutions":["Add or remove edges so the graph has 0 odd-degree vertices (Eulerian circuit) or exactly 2 (Eulerian path).","Check vertex degrees before calling eulerianPath and reject graphs that are not Eulerian.","Use a general traversal such as DFS or BFS if the graph is not Eulerian."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"85293e3e2b88f4d2ce330d956b139cf628aa1e82","analyzedAt":"2026-08-24T05:59:10.417Z","schemaVersion":2},"datasetVersion":"2026-08-24T07:17:09.176Z"}