use of org.opennms.features.topology.api.topo.SimpleConnector in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method connectCloudMacVertices.
protected final LinkdEdge connectCloudMacVertices(String targetmac, VertexRef sourceRef, VertexRef targetRef, String nameSpace) {
SimpleConnector source = new SimpleConnector(sourceRef.getNamespace(), sourceRef.getId() + "-" + targetRef.getId() + "-connector", sourceRef);
SimpleConnector target = new SimpleConnector(targetRef.getNamespace(), targetRef.getId() + "-" + sourceRef.getId() + "-connector", targetRef);
LinkdEdge edge = new LinkdEdge(nameSpace, targetRef.getId() + ":" + targetmac, source, target);
edge.setTargetEndPoint(targetmac);
addEdges(edge);
return edge;
}
use of org.opennms.features.topology.api.topo.SimpleConnector in project opennms by OpenNMS.
the class SFreeTopologyProvider method createBARandomTopology.
private void createBARandomTopology(int numberOfNodes, double averageNumberofNeighboors) {
Map<Integer, SimpleLeafVertex> nodes = new HashMap<Integer, SimpleLeafVertex>();
List<AbstractEdge> edges = new ArrayList<AbstractEdge>();
for (int i = 0; i < 2 * averageNumberofNeighboors; i++) {
LOG.debug("Creating First Cluster from: {}", i);
int j = (i + 1) % ((int) Math.round(2 * averageNumberofNeighboors));
SimpleLeafVertex vertexi = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_SFREE, Integer.toString(i), 0, 0);
vertexi.setIconKey("sfree.system");
vertexi.setLabel("BarabasiAlbertNode" + i);
if (!nodes.containsKey(i)) {
nodes.put(i, vertexi);
LOG.debug("Added Node: {}", vertexi.getId());
}
SimpleLeafVertex vertexj = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_SFREE, Integer.toString(j), 0, 0);
vertexj.setIconKey("sfree.system");
vertexj.setLabel("BarabasiAlbertNode" + j);
if (!nodes.containsKey(j)) {
nodes.put(j, vertexj);
LOG.debug("Added Node: {}", vertexj.getId());
}
String edgeId = "link:" + i + "-" + j;
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);
}
Random r = new Random((new Date()).getTime());
for (int i = ((int) Math.floor(2 * averageNumberofNeighboors)); i < numberOfNodes; i++) {
SimpleLeafVertex vertexi = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_SFREE, Integer.toString(i), 0, 0);
vertexi.setIconKey("sfree.system");
vertexi.setLabel("BarabasiAlbertNode" + i);
nodes.put(i, vertexi);
LOG.debug("Adding Node: {}", i);
for (int times = 0; times < averageNumberofNeighboors; times++) {
AbstractEdge edge;
// choose node to attach to
double d = r.nextDouble() * nodes.size();
LOG.debug("Generated random position: {}", d);
Long j = (long) d;
LOG.debug("Try Adding edge: {}--->{}", j, i);
String edgeId = "link:" + i + "-" + j.intValue();
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);
}
// m links added
}
addVertices(nodes.values().toArray(new Vertex[] {}));
addEdges(edges.toArray(new Edge[] {}));
}
use of org.opennms.features.topology.api.topo.SimpleConnector in project opennms by OpenNMS.
the class SFreeTopologyProvider method createERRandomTopology.
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[] {}));
}
Aggregations