public <T extends Edge> T removeEdge(int index) { Edge edge = getEdge(index); if (edge == null) { if (strictChecking) throw new ElementNotFoundException("Edge #" + index + " not found. Cannot remove it."); return null; } return removeEdge(edge); }
public <T extends Edge> T removeEdge(String id) { Edge edge = getEdge(id); if (edge == null) { if (strictChecking) throw new ElementNotFoundException("Edge \"" + id + "\" not found. Cannot remove it."); return null; } return removeEdge(edge); }
public <T extends Edge> T removeEdge(int index) { Edge edge = getEdge(index); if (edge == null) { if (strictChecking) throw new ElementNotFoundException("Edge #" + index + " not found. Cannot remove it."); return null; } return removeEdge(edge); }
public <T extends Node> T removeNode(String id) { AbstractNode node = getNode(id); if (node == null) { if (strictChecking) throw new ElementNotFoundException("Node \"" + id + "\" not found. Cannot remove it."); return null; } return removeNode(node); }
public <T extends Node> T removeNode(int index) { Node node = getNode(index); if (node == null) { if (strictChecking) throw new ElementNotFoundException("Node #" + index + " not found. Cannot remove it."); return null; } return removeNode(node); }
public <T extends Node> T removeNode(String id) { AbstractNode node = getNode(id); if (node == null) { if (strictChecking) throw new ElementNotFoundException("Node \"" + id + "\" not found. Cannot remove it."); return null; } return removeNode(node); }
public <T extends Node> T removeNode(int index) { Node node = getNode(index); if (node == null) { if (strictChecking) throw new ElementNotFoundException("Node #" + index + " not found. Cannot remove it."); return null; } return removeNode(node); }
public <T extends Edge> T removeEdge(String id) { Edge edge = getEdge(id); if (edge == null) { if (strictChecking) throw new ElementNotFoundException("Edge \"" + id + "\" not found. Cannot remove it."); return null; } return removeEdge(edge); }
protected Element getElement(Graph g) { Element e; switch (type) { case NODE: e = g.getNode(elementId); break; case EDGE: e = g.getEdge(elementId); break; case GRAPH: e = g; break; default: e = null; } if (e == null) throw new ElementNotFoundException(); return e; }
protected Element getElement(Graph g) { Element e; switch (type) { case NODE: e = g.getNode(elementId); break; case EDGE: e = g.getEdge(elementId); break; case GRAPH: e = g; break; default: e = null; } if (e == null) throw new ElementNotFoundException(); return e; }
public <T extends Edge> T removeEdge(String from, String to) { Node fromNode = getNode(from); Node toNode = getNode(to); if (fromNode == null || toNode == null) { if (strictChecking) throw new ElementNotFoundException( "Cannot remove the edge. The node \"%s\" does not exist", fromNode == null ? from : to); return null; } return removeEdge(fromNode, toNode); }
public <T extends Edge> T removeEdge(int fromIndex, int toIndex) { Node fromNode = getNode(fromIndex); Node toNode = getNode(toIndex); if (fromNode == null || toNode == null) { if (strictChecking) throw new ElementNotFoundException( "Cannot remove the edge. The node #%d does not exist", fromNode == null ? fromIndex : toIndex); return null; } return removeEdge(fromNode, toNode); }
throw new ElementNotFoundException("node \"%s\"", from); throw new ElementNotFoundException("node \"%s\"", to);
public <T extends Edge> T removeEdge(String from, String to) { Node fromNode = getNode(from); Node toNode = getNode(to); if (fromNode == null || toNode == null) { if (strictChecking) throw new ElementNotFoundException( "Cannot remove the edge. The node \"%s\" does not exist", fromNode == null ? from : to); return null; } return removeEdge(fromNode, toNode); }
public <T extends Edge> T removeEdge(int fromIndex, int toIndex) { Node fromNode = getNode(fromIndex); Node toNode = getNode(toIndex); if (fromNode == null || toNode == null) { if (strictChecking) throw new ElementNotFoundException( "Cannot remove the edge. The node #%d does not exist", fromNode == null ? fromIndex : toIndex); return null; } return removeEdge(fromNode, toNode); }
throw new ElementNotFoundException("node \"%s\"", from); throw new ElementNotFoundException("node \"%s\"", to);
public <T extends Edge> T removeEdge(Node node1, Node node2) { AbstractEdge edge = node1.getEdgeToward(node2); if (edge == null) { if (strictChecking) throw new ElementNotFoundException( "There is no edge from \"%s\" to \"%s\". Cannot remove it.", node1.getId(), node2.getId()); return null; } return removeEdge(edge); }
public <T extends Edge> T removeEdge(Node node1, Node node2) { AbstractEdge edge = node1.getEdgeToward(node2); if (edge == null) { if (strictChecking) throw new ElementNotFoundException( "There is no edge from \"%s\" to \"%s\". Cannot remove it.", node1.getId(), node2.getId()); return null; } return removeEdge(edge); }
public void compute() { Node source = flowGraph.getNode(sourceId); Node sink = flowGraph.getNode(sinkId); if (source == null) throw new ElementNotFoundException("node \"%s\"", sourceId); if (sink == null) throw new ElementNotFoundException("node \"%s\"", sinkId); checkArrays(); loadCapacitiesFromAttribute(); for (int i = 0; i < flowGraph.getEdgeCount(); i++) { Edge e = flowGraph.getEdge(i); setFlow(e.getNode0(), e.getNode1(), 0); setFlow(e.getNode1(), e.getNode0(), 0); } double minCf; LinkedList<Node> path = new LinkedList<Node>(); while ((minCf = findPath(path, source, sink)) > 0) { for (int i = 1; i < path.size(); i++) { Node u = path.get(i - 1); Node v = path.get(i); setFlow(u, v, getFlow(u, v) + minCf); setFlow(v, u, getFlow(v, u) - minCf); } path.clear(); } double flow = 0; for (int i = 0; i < source.getDegree(); i++) flow += getFlow(source, source.getEdge(i).getOpposite(source)); maximumFlow = flow; }
public void compute() { Node source = flowGraph.getNode(sourceId); Node sink = flowGraph.getNode(sinkId); if (source == null) throw new ElementNotFoundException("node \"%s\"", sourceId); if (sink == null) throw new ElementNotFoundException("node \"%s\"", sinkId); checkArrays(); loadCapacitiesFromAttribute(); for (int i = 0; i < flowGraph.getEdgeCount(); i++) { Edge e = flowGraph.getEdge(i); setFlow(e.getNode0(), e.getNode1(), 0); setFlow(e.getNode1(), e.getNode0(), 0); } double minCf; LinkedList<Node> path = new LinkedList<Node>(); while ((minCf = findPath(path, source, sink)) > 0) { for (int i = 1; i < path.size(); i++) { Node u = path.get(i - 1); Node v = path.get(i); setFlow(u, v, getFlow(u, v) + minCf); setFlow(v, u, getFlow(v, u) - minCf); } path.clear(); } double flow = 0; for (int i = 0; i < source.getDegree(); i++) flow += getFlow(source, source.getEdge(i).getOpposite(source)); maximumFlow = flow; }