/** * Checks if an edge is incident to this node. Utility method that can be * useful in subclasses. * * @param e * an edge * @return {@code true} if {@code e} is incident edge for this node. */ public boolean isIncidentEdge(Edge e) { return e.getSourceNode() == this || e.getTargetNode() == this; } }
/** * Checks if an edge is incident to this node. Utility method that can be * useful in subclasses. * * @param e * an edge * @return {@code true} if {@code e} is incident edge for this node. */ public boolean isIncidentEdge(Edge e) { return e.getSourceNode() == this || e.getTargetNode() == this; } }
private void fillDistanceMapUnweighted(Node[] theSortedArray) { for (Node aNode : theSortedArray) { for (Edge anEdge : aNode.getEachEnteringEdge()) { Node aSourceNode = anEdge.getSourceNode(); Node aTargetNode = anEdge.getTargetNode(); Double aMaxDistance = Math.max(distanceMap.get(aTargetNode), distanceMap.get(aSourceNode)) + 1; distanceMap.put(aTargetNode, aMaxDistance); } } }
public <T extends Node> T getSourceNode() { T n; sg.elementLock.lock(); n = sg.getNode(wrappedElement.getSourceNode().getIndex()); sg.elementLock.unlock(); return n; }
public <T extends Node> T getSourceNode() { T n; sg.elementLock.lock(); n = sg.getNode(wrappedElement.getSourceNode().getIndex()); sg.elementLock.unlock(); return n; }
private static String toString(Graph g) { StringBuilder buffer = new StringBuilder(); buffer.append("id=\"").append(g.getId()).append("\" node={"); for (Node n : g) buffer.append("\"").append(n.getId()).append("\", "); buffer.append("}, edges={"); for (Edge e : g.getEachEdge()) buffer.append("\"").append(e.getId()).append("\":\"") .append(e.getSourceNode().getId()).append("\"--\"") .append(e.getTargetNode().getId()).append("\", "); buffer.append("}"); return buffer.toString(); } }
private static String toString(Graph g) { StringBuilder buffer = new StringBuilder(); buffer.append("id=\"").append(g.getId()).append("\" node={"); for (Node n : g) buffer.append("\"").append(n.getId()).append("\", "); buffer.append("}, edges={"); for (Edge e : g.getEachEdge()) buffer.append("\"").append(e.getId()).append("\":\"") .append(e.getSourceNode().getId()).append("\"--\"") .append(e.getTargetNode().getId()).append("\", "); buffer.append("}"); return buffer.toString(); } }
/** * Checks if an edge enters this node. Utility method that can be useful in * subclasses. * * @param e * an edge * @return {@code true} if {@code e} is entering edge for this node. */ public boolean isEnteringEdge(Edge e) { return e.getTargetNode() == this || (!e.isDirected() && e.getSourceNode() == this); }
/** * Checks if an edge enters this node. Utility method that can be useful in * subclasses. * * @param e * an edge * @return {@code true} if {@code e} is entering edge for this node. */ public boolean isEnteringEdge(Edge e) { return e.getTargetNode() == this || (!e.isDirected() && e.getSourceNode() == this); }
/** * Checks if an edge leaves this node. Utility method that can be useful in * subclasses. * * @param e * an edge * @return {@code true} if {@code e} is leaving edge for this node. */ public boolean isLeavingEdge(Edge e) { return e.getSourceNode() == this || (!e.isDirected() && e.getTargetNode() == this); }
private void fillDistanceMapWeighted(Node[] theSortedArray) { for (Node aNode : theSortedArray) { for (Edge anEdge : aNode.getEachEnteringEdge()) { Node aSourceNode = anEdge.getSourceNode(); Node aTargetNode = anEdge.getTargetNode(); double aWeight = anEdge.getNumber(getWeightAttribute()); Double aMaxDistance = Math.max(distanceMap.get(aTargetNode), distanceMap.get(aSourceNode) + aWeight); distanceMap.put(aTargetNode, aMaxDistance); } } }
/** * Checks if an edge leaves this node. Utility method that can be useful in * subclasses. * * @param e * an edge * @return {@code true} if {@code e} is leaving edge for this node. */ public boolean isLeavingEdge(Edge e) { return e.getSourceNode() == this || (!e.isDirected() && e.getTargetNode() == this); }
public double getFlow(Node u, Node v) { Edge e = u.getEdgeBetween(v); if (e.getSourceNode() == u) return flows[e.getIndex()]; else return flows[e.getIndex() + n]; }
public void setCapacity(Node u, Node v, double capacity) { Edge e = u.getEdgeBetween(v); if (e.getSourceNode() == u) capacities[e.getIndex()] = capacity; else capacities[e.getIndex() + n] = capacity; }
public double getFlow(Node u, Node v) { Edge e = u.getEdgeBetween(v); if (e.getSourceNode() == u) return flows[e.getIndex()]; else return flows[e.getIndex() + n]; }
public void setFlow(Node u, Node v, double flow) { Edge e = u.getEdgeBetween(v); if (e.getSourceNode() == u) flows[e.getIndex()] = flow; else flows[e.getIndex() + n] = flow; }
public double getCapacity(Node u, Node v) { Edge e = u.getEdgeBetween(v); if (e == null) System.err.printf("no edge between %s and %s\n", u.getId(), v .getId()); if (e.getSourceNode() == u) return capacities[e.getIndex()]; else return capacities[e.getIndex() + n]; }
public void edgeRemoved(String sourceId, long timeId, String edgeId) { Edge edge = g.getEdge(edgeId); for (String key : edge.getAttributeKeySet()) edgeAttributeRemoved(sourceId, timeId, edgeId, key); Event e; e = new EdgeRemoved(edgeId, edge.getSourceNode().getId(), edge .getTargetNode().getId(), edge.isDirected()); events.add(e); }
public void edgeRemoved(String sourceId, long timeId, String edgeId) { Edge edge = g.getEdge(edgeId); for (String key : edge.getAttributeKeySet()) edgeAttributeRemoved(sourceId, timeId, edgeId, key); Event e; e = new EdgeRemoved(edgeId, edge.getSourceNode().getId(), edge .getTargetNode().getId(), edge.isDirected()); events.add(e); }
protected void modifyCost(String edgeId, double cval) { Edge e = env.getEdge(edgeId); if (e.isDirected()) modifyCost(getState(e.getSourceNode()), getState(e.getTargetNode()), cval); else { modifyCost(getState(e.getNode0()), getState(e.getNode1()), cval); modifyCost(getState(e.getNode1()), getState(e.getNode0()), cval); } }