public static String defaultGraphToString(Graph<Node, DefaultLink> graph) { if (graph == null) { logger.debug("The input graph is null."); return ""; } StringBuffer sb = new StringBuffer(); sb.append("*** Nodes ***\n"); for (Node n : graph.vertexSet()) { sb.append(n.getLocalId()); sb.append("\n"); } sb.append("*** Links ***\n"); for (DefaultLink edge : graph.edgeSet()) { sb.append("("); sb.append(edge.getId()); sb.append(" - w=" + edge.getWeight()); sb.append("\n"); } //sb.append("------------------------------------------"); return sb.toString(); }
public static void printLabeledGraph(Graph<Node, LabeledLink> graph) { if (graph == null) { logger.debug("graph is null."); return; } StringBuffer sb = new StringBuffer(); sb.append("*** Nodes ***\n"); for (Node n : graph.vertexSet()) { sb.append(n.getLocalId()); sb.append("\n"); } sb.append("*** Links ***\n"); for (DefaultLink link : graph.edgeSet()) { sb.append(link.getId()); sb.append(", "); sb.append(link.getType().toString()); sb.append(", "); sb.append(link.getWeight()); sb.append("\n"); } // sb.append("------------------------------------------"); logger.debug(sb.toString()); }
public static void printGraph(Graph<Node, DefaultLink> graph) { if (graph == null) { logger.debug("graph is null."); return; } StringBuffer sb = new StringBuffer(); sb.append("*** Nodes ***\n"); for (Node n : graph.vertexSet()) { sb.append(n.getLocalId()); sb.append("\n"); } sb.append("*** Links ***\n"); for (DefaultLink link : graph.edgeSet()) { sb.append(link.getId()); sb.append(", "); sb.append(link.getType().toString()); sb.append(", "); sb.append(link.getWeight()); sb.append("\n"); } // sb.append("------------------------------------------"); logger.debug(sb.toString()); }
writer.name("weight").value(link.getWeight()); writer.name("type").value(link.getType().toString()); if (link instanceof CompactObjectPropertyLink)
public boolean removeLink(DefaultLink link) { if (super.removeLink(link)) { SteinerNode n1 = new SteinerNode(link.getSource().getId()); SteinerNode n2 = new SteinerNode(link.getTarget().getId()); SteinerEdge e = new SteinerEdge(n1, link.getId(), n2, (float)link.getWeight()); // getTopKGraph().get(n1).remove(e); getTopKGraph().get(n2).remove(e); return true; } else return false; }
public boolean addLink(Node source, Node target, DefaultLink link) { if (super.addLink(source, target, link)) { SteinerNode n1 = new SteinerNode(source.getId()); SteinerNode n2 = new SteinerNode(target.getId()); SteinerEdge e = new SteinerEdge(n1, link.getId(), n2, (float)link.getWeight()); if (link instanceof LabeledLink) { e.setModelIds(((LabeledLink)link).getModelIds()); e.setForced(((LabeledLink)link).getStatus() == LinkStatus.ForcedByUser); } // getTopKGraph().get(n1).add(e); getTopKGraph().get(n2).add(e); // each node only stores its incoming links return true; } else return false; }
tree.setEdgeWeight(newLink, link.getWeight()); if (allowedChangingGraph) this.graphBuilder.addLink(link.getSource(), link.getTarget(), newLink);
this.addLink(source, target, l, link.getWeight()); else this.addLink(source, target, l);
newId = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId()); DefaultLink copyLink = l.getCopy(newId); this.addLink(source, target, copyLink, l.getWeight()); newId = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId()); DefaultLink copyLink = l.getCopy(newId); this.addLink(source, target, copyLink, l.getWeight());
edgeLabel += "w=" + roundDecimals(e.getWeight(), 6);