public void addLink(DefaultLink e) { if (this.edgeList.isEmpty()) this.startNode = e.getSource(); this.edgeList.add(e); this.endNode = e.getTarget(); }
public void addLinkToHead(DefaultLink e) { if (this.edgeList.isEmpty()) this.endNode = e.getTarget(); this.edgeList.add(0, e); this.startNode = e.getSource(); }
public static Set<Node> getInNeighbors(DirectedGraph<Node, DefaultLink> g, Node n) { Set<Node> neighbors = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return neighbors; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { neighbors.add(l.getSource()); } } return neighbors; }
Node source, target; source = link.getSource(); target = link.getTarget();
target = e.getSource();
linksWithSameStatus.remove(link); Node source = link.getSource(); Set<LabeledLink> sourceLinks = nodeOutgoingLinks.get(source.getId()); if(sourceLinks != null)
public static DirectedGraph<Node, DefaultLink> asDirectedGraph(UndirectedGraph<Node, DefaultLink> undirectedGraph) { if (undirectedGraph == null) { logger.debug("graph is null."); return null; } DirectedGraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<>(DefaultLink.class); for (Node v : undirectedGraph.vertexSet()) g.addVertex(v); for (DefaultLink e: undirectedGraph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public static HashMap<SemanticType, LabeledLink> getDomainLinks(DirectedGraph<Node, DefaultLink> g, ColumnNode n, List<SemanticType> semanticTypes) { HashMap<SemanticType, LabeledLink> domainLinks = new HashMap<>(); if (g == null || n == null || semanticTypes == null || !g.vertexSet().contains(n)) return domainLinks; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (SemanticType st : semanticTypes) { for (DefaultLink l : incomingLinks) { if (st.getDomain().getUri().equalsIgnoreCase(l.getSource().getUri()) && st.getType().getUri().equalsIgnoreCase(l.getUri())) { if (l instanceof LabeledLink) domainLinks.put(st, (LabeledLink)l); } } } } return domainLinks; }
public static DirectedWeightedMultigraph<Node, DefaultLink> asDefaultGraph(DirectedWeightedMultigraph<Node, LabeledLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } DirectedWeightedMultigraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<>(DefaultLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public static UndirectedGraph<Node, DefaultLink> asDefaultGraph(UndirectedGraph<Node, LabeledLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } UndirectedGraph<Node, DefaultLink> g = new WeightedMultigraph<>(DefaultLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public static DirectedWeightedMultigraph<Node, LabeledLink> asLabeledGraph(DirectedWeightedMultigraph<Node, DefaultLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } DirectedWeightedMultigraph<Node, LabeledLink> g = new DirectedWeightedMultigraph<>(LabeledLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) if (e instanceof LabeledLink) g.addEdge(e.getSource(), e.getTarget(), (LabeledLink)e); return g; }
public static WeightedMultigraph<Node, LabeledLink> asLabeledGraph(WeightedMultigraph<Node, DefaultLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } WeightedMultigraph<Node, LabeledLink> g = new WeightedMultigraph<>(LabeledLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) if (e instanceof LabeledLink) g.addEdge(e.getSource(), e.getTarget(), (LabeledLink)e); return g; }
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 void changeLinkWeight(DefaultLink link, double weight) { super.changeLinkWeight(link, weight); SteinerNode n1 = new SteinerNode(link.getSource().getId()); SteinerNode n2 = new SteinerNode(link.getTarget().getId()); SteinerEdge e = new SteinerEdge(n1, link.getId(), n2, (float)weight); if (getTopKGraph().get(n2).remove(e)) { if (link instanceof LabeledLink) { e.setModelIds(((LabeledLink)link).getModelIds()); e.setForced(((LabeledLink)link).getStatus() == LinkStatus.ForcedByUser); } getTopKGraph().get(n2).add(e); } }
sourceId = link.getSource().getId(); targetId = link.getTarget().getId(); tree.addEdge(link.getSource(), link.getTarget(), newLink); tree.setEdgeWeight(newLink, link.getWeight()); if (allowedChangingGraph) this.graphBuilder.addLink(link.getSource(), link.getTarget(), newLink); logger.error("Something is going wrong. " + "There should be at least one possible object property between " + link.getSource().getLabel().getUri() + " and " + link.getTarget().getLabel().getUri()); return;
source = link.getSource(); target = link.getTarget();
if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { source = l.getSource(); if (source instanceof ColumnNode) continue; target = newNode;