@Override public AbstractEdge clone() { return new AbstractEdge(this); }
@Override public AbstractEdge clone() { return new AbstractEdge(this); }
@Override public AbstractEdge clone() { return new AbstractEdge(this); }
private void createERRandomTopology(int numberOfNodes, double averageNumberofNeighboors) { Map<Integer,SimpleLeafVertex> nodes = new HashMap<Integer, SimpleLeafVertex>(); List<AbstractEdge> edges = new ArrayList<>(); for (Integer i=0; i< numberOfNodes ;i++) { SimpleLeafVertex vertex = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_SFREE, Integer.toString(i), 0, 0); vertex.setIconKey("sfree.system"); vertex.setLabel("ErdosReniyNode"+i); nodes.put(i,vertex); } Double z = 0.5*(numberOfNodes-1); // Double p = averageNumberofNeighboors/z; Random r = new Random((new Date()).getTime()); for (Integer start=0; start < numberOfNodes; start++) { for (Integer end = start+1; end<numberOfNodes;end++) { if (z*r.nextDouble()<averageNumberofNeighboors) { String edgeId = "link:"+start+"-"+end; SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(start).getId()+"-"+edgeId+"-connector", nodes.get(start)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(end).getId()+"-"+edgeId+"-connector", nodes.get(end)); edges.add(new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target)); } } } addVertices(nodes.values().toArray(new Vertex[] {})); addEdges(edges.toArray(new Edge[] {})); }
private void createERRandomTopology(int numberOfNodes, double averageNumberofNeighboors) { Map<Integer,SimpleLeafVertex> nodes = new HashMap<Integer, SimpleLeafVertex>(); List<AbstractEdge> edges = new ArrayList<AbstractEdge>(); for (Integer i=0; i< numberOfNodes ;i++) { SimpleLeafVertex vertex = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_SFREE, Integer.toString(i), 0, 0); vertex.setIconKey("sfree.system"); vertex.setLabel("ErdosReniyNode"+i); nodes.put(i,vertex); } Double z = 0.5*(numberOfNodes-1); // Double p = averageNumberofNeighboors/z; Random r = new Random((new Date()).getTime()); for (Integer start=0; start < numberOfNodes; start++) { for (Integer end = start+1; end<numberOfNodes;end++) { if (z*r.nextDouble()<averageNumberofNeighboors) { String edgeId = "link:"+start+"-"+end; SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(start).getId()+"-"+edgeId+"-connector", nodes.get(start)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(end).getId()+"-"+edgeId+"-connector", nodes.get(end)); edges.add(new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target)); } } } addVertices(nodes.values().toArray(new Vertex[] {})); addEdges(edges.toArray(new Edge[] {})); }
SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(i).getId()+"-"+edgeId+"-connector", nodes.get(i)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(j).getId()+"-"+edgeId+"-connector", nodes.get(j)); edges.add(new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target)); LOG.debug("Added Link: {}", edgeId); SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(i).getId()+"-"+edgeId+"-connector", nodes.get(i)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(j.intValue()).getId()+"-"+edgeId+"-connector", nodes.get(j.intValue())); edge = new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target); if( i == j.intValue() ) continue; edges.add(edge);
SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(i).getId()+"-"+edgeId+"-connector", nodes.get(i)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(j).getId()+"-"+edgeId+"-connector", nodes.get(j)); edges.add(new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target)); LOG.debug("Added Link: {}", edgeId); SimpleConnector source = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(i).getId()+"-"+edgeId+"-connector", nodes.get(i)); SimpleConnector target = new SimpleConnector(TOPOLOGY_NAMESPACE_SFREE, nodes.get(j.intValue()).getId()+"-"+edgeId+"-connector", nodes.get(j.intValue())); edge = new AbstractEdge(TOPOLOGY_NAMESPACE_SFREE, edgeId, source, target); if( i == j.intValue() ) continue; edges.add(edge);
protected final AbstractEdge connectVertices(String id, VertexRef sourceId, VertexRef targetId, String namespace) { if (sourceId == null) { if (targetId == null) { LOG.warn("Source and target vertices are null"); return null; } else { LOG.warn("Source vertex is null"); return null; } } else if (targetId == null) { LOG.warn("Target vertex is null"); return null; } SimpleConnector source = new SimpleConnector(sourceId.getNamespace(), sourceId.getId()+"-"+id+"-connector", sourceId); SimpleConnector target = new SimpleConnector(targetId.getNamespace(), targetId.getId()+"-"+id+"-connector", targetId); AbstractEdge edge = new AbstractEdge(namespace, id, source, target); addEdges(edge); return edge; }
protected final AbstractEdge connectVertices(String id, VertexRef sourceId, VertexRef targetId, String namespace) { if (sourceId == null) { if (targetId == null) { LOG.warn("Source and target vertices are null"); return null; } else { LOG.warn("Source vertex is null"); return null; } } else if (targetId == null) { LOG.warn("Target vertex is null"); return null; } SimpleConnector source = new SimpleConnector(sourceId.getNamespace(), sourceId.getId()+"-"+id+"-connector", sourceId); SimpleConnector target = new SimpleConnector(targetId.getNamespace(), targetId.getId()+"-"+id+"-connector", targetId); AbstractEdge edge = new AbstractEdge(namespace, id, source, target); addEdges(edge); return edge; }
protected final AbstractEdge connectVertices(String id, VertexRef sourceId, VertexRef targetId, String namespace) { if (sourceId == null) { if (targetId == null) { LOG.warn("Source and target vertices are null"); return null; } else { LOG.warn("Source vertex is null"); return null; } } else if (targetId == null) { LOG.warn("Target vertex is null"); return null; } SimpleConnector source = new SimpleConnector(sourceId.getNamespace(), sourceId.getId()+"-"+id+"-connector", sourceId); SimpleConnector target = new SimpleConnector(targetId.getNamespace(), targetId.getId()+"-"+id+"-connector", targetId); AbstractEdge edge = new AbstractEdge(namespace, id, source, target); addEdges(edge); return edge; }
private void load() { resetContainer(); for (OnmsApplication application : applicationDao.findAll()) { ApplicationVertex applicationVertex = new ApplicationVertex(application); addVertices(applicationVertex); for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) { final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService); applicationVertex.addChildren(serviceVertex); addVertices(serviceVertex); // connect with application String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId()); Edge edge = new AbstractEdge(getNamespace(), id, applicationVertex, serviceVertex); addEdges(edge); } } }
this.sparseGraph.addVertex(vertexChild); this.sparseGraph.addVertex(vertexParent); this.sparseGraph.addEdge(new AbstractEdge(NAMESPACE, String.valueOf(edgeID), vertexParent, vertexChild), vertexParent, vertexChild, EdgeType.DIRECTED); edgeID++;
private void load() { resetContainer(); for (OnmsApplication application : applicationDao.findAll()) { ApplicationVertex applicationVertex = new ApplicationVertex(application); addVertices(applicationVertex); for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) { final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService); applicationVertex.addChildren(serviceVertex); addVertices(serviceVertex); // connect with application String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId()); Edge edge = new AbstractEdge(getNamespace(), id, applicationVertex, serviceVertex); addEdges(edge); } } }
this.sparseGraph.addVertex(vertexChild); this.sparseGraph.addVertex(vertexParent); this.sparseGraph.addEdge(new AbstractEdge(NAMESPACE, String.valueOf(edgeID), vertexParent, vertexChild), vertexParent, vertexChild, EdgeType.DIRECTED); edgeID++;
private void load() { resetContainer(); for (OnmsApplication application : applicationDao.findAll()) { ApplicationVertex applicationVertex = new ApplicationVertex(application); addVertices(applicationVertex); for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) { final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService); applicationVertex.addChildren(serviceVertex); addVertices(serviceVertex); // connect with application String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId()); Edge edge = new AbstractEdge(getEdgeNamespace(), id, applicationVertex, serviceVertex); addEdges(edge); } } }
sparseGraph.getVertices().forEach(eachVertex -> { topologyServiceClient.getOppositeVertices(eachVertex).forEach(oppositeVertex -> { sparseGraph.addEdge(new AbstractEdge("$$outer-space$$", "" + idGenerator.nextId(), eachVertex, oppositeVertex), eachVertex, oppositeVertex); }); }); sparseGraph.addEdge(new AbstractEdge("$$outer-space$$", "" + idGenerator.nextId(), rootVertex, eachVertex), rootVertex, eachVertex);
sparseGraph.getVertices().forEach(eachVertex -> { topologyServiceClient.getOppositeVertices(eachVertex).forEach(oppositeVertex -> { sparseGraph.addEdge(new AbstractEdge("$$outer-space$$", "" + idGenerator.nextId(), eachVertex, oppositeVertex), eachVertex, oppositeVertex); }); }); sparseGraph.addEdge(new AbstractEdge("$$outer-space$$", "" + idGenerator.nextId(), rootVertex, eachVertex), rootVertex, eachVertex);
public SimpleGraphBuilder edge(String id, String srcId, String tgtId) { VertexRef srcVertex = m_graphProvider.getVertex(ns(), srcId); if (srcVertex == null) { srcVertex = new DefaultVertexRef(ns(), srcId); } VertexRef tgtVertex = m_graphProvider.getVertex(ns(), tgtId); if (tgtVertex == null) { tgtVertex = new DefaultVertexRef(ns(), tgtId); } SimpleConnector source = new SimpleConnector(ns(), srcId+"-"+id+"-connector", srcVertex); SimpleConnector target = new SimpleConnector(ns(), tgtId+"-"+id+"-connector", tgtVertex); m_currentEdge = new AbstractEdge(ns(), id, source, target); source.setEdge(m_currentEdge); target.setEdge(m_currentEdge); m_graphProvider.addEdges(m_currentEdge); return this; }
public SimpleGraphBuilder edge(String id, String srcId, String tgtId) { VertexRef srcVertex = m_graphProvider.getVertex(ns(), srcId); if (srcVertex == null) { srcVertex = new DefaultVertexRef(ns(), srcId); } VertexRef tgtVertex = m_graphProvider.getVertex(ns(), tgtId); if (tgtVertex == null) { tgtVertex = new DefaultVertexRef(ns(), tgtId); } SimpleConnector source = new SimpleConnector(ns(), srcId+"-"+id+"-connector", srcVertex); SimpleConnector target = new SimpleConnector(ns(), tgtId+"-"+id+"-connector", tgtVertex); m_currentEdge = new AbstractEdge(ns(), id, source, target); source.setEdge(m_currentEdge); target.setEdge(m_currentEdge); m_graphProvider.addEdges(m_currentEdge); return this; }