/** * Tests whether a complete unique path exists in a graph * using Euler's Theorem. * * @param graph the subgraph containing the edges * @return <code>true</code> if a sequence exists */ private boolean hasSequence(Subgraph graph) { int oddDegreeCount = 0; for (Iterator i = graph.nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (node.getDegree() % 2 == 1) oddDegreeCount++; } return oddDegreeCount <= 2; }
private static Node findLowestDegreeNode(Subgraph graph) { int minDegree = Integer.MAX_VALUE; Node minDegreeNode = null; for (Iterator i = graph.nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (minDegreeNode == null || node.getDegree() < minDegree) { minDegree = node.getDegree(); minDegreeNode = node; } } return minDegreeNode; }
/** * Tests whether a complete unique path exists in a graph * using Euler's Theorem. * * @param graph the subgraph containing the edges * @return <code>true</code> if a sequence exists */ private boolean hasSequence(Subgraph graph) { int oddDegreeCount = 0; for (Iterator i = graph.nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (node.getDegree() % 2 == 1) oddDegreeCount++; } return oddDegreeCount <= 2; }
private static Node findLowestDegreeNode(Subgraph graph) { int minDegree = Integer.MAX_VALUE; Node minDegreeNode = null; for (Iterator i = graph.nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (minDegreeNode == null || node.getDegree() < minDegree) { minDegree = node.getDegree(); minDegreeNode = node; } } return minDegreeNode; }