/** * Tests whether an undirected arc exists between two nodes in the graph * * @param node1 graph node * @param node2 graph node * @return true if arc exists */ public boolean undirArcExists(Node node1, Node node2) { for (UndirectedArc undirArc : undirArcList) { if (undirArc.nodeExists(node1) && undirArc.nodeExists(node2)) { return true; } } return false; }
/** * Gets undirected arc between two nodes in the graph * * @param node1 graph node * @param node2 graph node * @return Undirected arc between nodes if arc exists * @throws Exception if arc does not exist */ public UndirectedArc getUndirArc(Node node1, Node node2) throws Exception { for (UndirectedArc undirArc : undirArcList) { if (undirArc.nodeExists(node1) && undirArc.nodeExists(node2)) { return undirArc; } } throw new Exception("Undirected arc does not exist between the nodes"); }