/** * As the base implementation here, all templates will be considered for each edge. */ @Override protected void populateEdgeTemplateMap() { if (templateCatalog.isPresent()) { for (FlowEdge flowEdge : this.weightedGraph.edgeSet()) { edgeTemplateMap.put(flowEdge.getEdgeIdentity(), templateCatalog.get(). getAllTemplates(). stream().map(jobTemplate -> jobTemplate.getUri()).collect(Collectors.toList())); } } }
public SortableSemanticModel_Old(SemanticModel semanticModel, SteinerNodes steinerNodes) { super(semanticModel); this.steinerNodes = steinerNodes; if (this.graph != null && !this.graph.edgeSet().isEmpty()) { this.cost = this.computeCost(); // this.frequency = this.computeFrequency(); // this.cohesion = this.computeCohesion(); // this.coherence = this.computeCoherence(); } }
private double computeCost() { double cost = 0.0; for (LabeledLink e : this.graph.edgeSet()) { cost += e.getWeight(); } return cost; }
public SortableSemanticModel_Old(SemanticModel semanticModel) { super(semanticModel); if (this.graph != null && !this.graph.edgeSet().isEmpty()) { this.cost = this.computeCost(); // this.frequency = this.computeFrequency(); // this.cohesion = this.computeCohesion(); // this.coherence = this.computeCoherence(); } }
private double computeCost() { double cost = 0.0; for (LabeledLink e : this.graph.edgeSet()) { cost += e.getWeight(); } return cost; }
public boolean isEmpty() { return (this.graphBuilder.getGraph().edgeSet().isEmpty() || this.steinerTree == null); }
/** * As the base implementation here, all templates will be considered for each edge. */ @Override protected void populateEdgeTemplateMap() { if (templateCatalog.isPresent()) { for (FlowEdge flowEdge : this.weightedGraph.edgeSet()) { edgeTemplateMap.put(flowEdge.getEdgeIdentity(), templateCatalog.get(). getAllTemplates(). stream().map(jobTemplate -> jobTemplate.getUri()).collect(Collectors.toList())); } } }
private void computeCoherence() { for (LabeledLink l : this.graph.edgeSet()) { linkCoherence.updateCoherence(this.getGraph(), l); } }
public void addClosureAndUpdateLinks(Set<InternalNode> internalNodes, Set<Node> addedNodes) { logger.debug("<enter"); if (addedNodes == null) addedNodes = new HashSet<>(); long start = System.currentTimeMillis(); float elapsedTimeSec; if (internalNodes != null) { Node[] nodes = internalNodes.toArray(new Node[0]); for (Node node : nodes) if (this.idToNodeMap.containsKey(node.getId())) addNodeClosure(node, addedNodes); } long addNodesClosure = System.currentTimeMillis(); elapsedTimeSec = (addNodesClosure - start)/1000F; logger.debug("time to add nodes closure: " + elapsedTimeSec); updateLinks(); long updateLinks = System.currentTimeMillis(); elapsedTimeSec = (updateLinks - addNodesClosure)/1000F; logger.debug("time to update links of the graph: " + elapsedTimeSec); logger.debug("total number of nodes in graph: " + this.graph.vertexSet().size()); logger.debug("total number of links in graph: " + this.graph.edgeSet().size()); logger.debug("exit>"); }
public SortableSemanticModel(SemanticModel semanticModel, SteinerNodes steinerNodes, boolean interactiveMode) { super(semanticModel); this.steinerNodes = steinerNodes; this.linkCoherence = new LinkCoherence(interactiveMode); if (this.graph != null && !this.graph.edgeSet().isEmpty()) { this.cost = this.computeCost(); this.computeCoherence(); } }
public SortableSemanticModel(SemanticModel semanticModel, boolean interactiveMode) { super(semanticModel); this.linkCoherence = new LinkCoherence(interactiveMode); if (this.graph != null && !this.graph.edgeSet().isEmpty()) { this.cost = this.computeCost(); this.computeCoherence(); } }
public void printModel(DirectedWeightedMultigraph<Node, LabeledLink> model) { logger.debug("Vertices: "); for(Node n : model.vertexSet()) { logger.debug("\t" + n.getId()); } logger.debug("Edges: "); for(LabeledLink l : model.edgeSet()) { logger.debug("\t" + l.getSource().getId() + " --> " + l.getTarget().getId()); } }
private Set<String> getTriples(DirectedWeightedMultigraph<Node, LabeledLink> g, HashMap<Node,String> nodeIds, boolean ignoreSemanticTypes, boolean ignoreColumnNodes) { String separator = "|"; Set<String> triples = new HashSet<>(); if (g == null) return triples; String s, p, o, triple; for (LabeledLink l : g.edgeSet()) { if (ignoreSemanticTypes && !(l.getTarget() instanceof InternalNode)) continue; s = nodeIds.get(l.getSource()); o = nodeIds.get(l.getTarget()); p = l.getLabel().getUri(); if (ignoreColumnNodes) triple = s + separator + p; else triple = s + separator + p + separator + o; // System.out.println(triple); triples.add(triple); } return triples; }
private void updateLinksPreferredByUI() { if (this.steinerTree == null) return; // Change the status of previously preferred links to normal Set<LabeledLink> linksInPreviousTree = this.getLinksByStatus(LinkStatus.PreferredByUI); Set<LabeledLink> linksForcedByUser = this.getLinksByStatus(LinkStatus.ForcedByUser); if (linksInPreviousTree != null) { LabeledLink[] links = linksInPreviousTree.toArray(new LabeledLink[0]); for (LabeledLink link : links) this.graphBuilder.changeLinkStatus(link, LinkStatus.Normal); } for (LabeledLink link: this.steinerTree.edgeSet()) { if (linksForcedByUser == null || !linksForcedByUser.contains(link)) { this.graphBuilder.changeLinkStatus(link, LinkStatus.PreferredByUI); logger.debug("link " + link.getId() + " has been added to preferred UI links."); } } }
@SuppressWarnings("unused") private static void getStatistics1(List<SemanticModel> semanticModels) { for (int i = 0; i < semanticModels.size(); i++) { SemanticModel source = semanticModels.get(i); int attributeCount = source.getColumnNodes().size(); int nodeCount = source.getGraph().vertexSet().size(); int linkCount = source.getGraph().edgeSet().size(); int datanodeCount = 0; int classNodeCount = 0; for (Node n : source.getGraph().vertexSet()) { if (n instanceof InternalNode) classNodeCount++; if (n instanceof ColumnNode) datanodeCount++; } System.out.println(attributeCount + "\t" + nodeCount + "\t" + linkCount + "\t" + classNodeCount + "\t" + datanodeCount); List<ColumnNode> columnNodes = source.getColumnNodes(); getStatistics2(columnNodes); } }
protected ModelLearningGraph(OntologyManager ontologyManager, ModelLearningGraphType type) throws IOException { this.ontologyManager = ontologyManager; this.totalNumberOfKnownModels = 0; File file = new File(getGraphJsonName()); if (!file.exists()) { this.initializeFromJsonRepository(); } else { logger.info("loading the alignment graph ..."); DirectedWeightedMultigraph<Node, DefaultLink> graph = GraphUtil.importJson(getGraphJsonName()); if (type == ModelLearningGraphType.Compact) this.graphBuilder = new GraphBuilderTopK(ontologyManager, graph); else this.graphBuilder = new GraphBuilder(ontologyManager, graph, false); this.nodeIdFactory = this.graphBuilder.getNodeIdFactory(); logger.info("loading is done!"); } if (this.graphBuilder.getGraph() != null) { logger.info("number of nodes: " + this.graphBuilder.getGraph().vertexSet().size()); logger.info("number of links: " + this.graphBuilder.getGraph().edgeSet().size()); } this.lastUpdateTime = System.currentTimeMillis(); }
public static void writeGraph(DirectedWeightedMultigraph<Node, DefaultLink> graph, JsonWriter writer, boolean writeNodeAnnotations, boolean writeLinkAnnotations) throws IOException { writer.beginObject(); writer.name("nodes"); writer.beginArray(); if (graph != null) for (Node n : graph.vertexSet()) writeNode(writer, n, writeNodeAnnotations); // writeNode(workspace, worksheet, writer, n); writer.endArray(); writer.name("links"); writer.beginArray(); if (graph != null) for (DefaultLink l : graph.edgeSet()) writeLink(writer, l, writeLinkAnnotations); writer.endArray(); writer.endObject(); }
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 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; }
Node target; for (DefaultLink link : graph.edgeSet()) {