use of org.jgrapht.graph.DirectedPseudograph in project admin-console-beta by connexta.
the class CreateFeatureDependencyGraph method createFeatureDependenciesGraph.
private DirectedGraph<Field, DependencyEdge> createFeatureDependenciesGraph(List<FeatureField> features) {
DirectedGraph<Field, DependencyEdge> graph = new DirectedPseudograph<>(DependencyEdge.class);
FEATURE_BUNDLE_VERTEX_PROV.getAttributes().forEach(attri -> exporter.registerAttribute(attri.getAttriName(), attri.getCategory(), attri.getType()));
features.forEach(graph::addVertex);
Map<String, FeatureField> featuresById = features.stream().collect(Collectors.toMap(FeatureField::id, f -> f));
for (FeatureField feature : features) {
for (String featId : feature.featDeps()) {
try {
Feature feat = featureUtils.getFeature(featId);
if (feat != null && featuresById.containsKey(feat.getId())) {
graph.addEdge(feature, featuresById.get(feat.getId()), DependencyEdge.create(null));
} else {
LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId);
}
} catch (Exception e) {
LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId, e);
}
}
feature.bundleDeps().forEach(dep -> {
graph.addVertex(dep);
graph.addEdge(feature, dep, DependencyEdge.create(null));
});
}
return graph;
}
use of org.jgrapht.graph.DirectedPseudograph in project Smack by igniterealtime.
the class ModularXmppClientToServerConnectionStateGraphTest method testStateGraphDotOutput.
@Test
public void testStateGraphDotOutput() throws IOException, ImportException {
URL stateGraphDotFileUrl = Resources.getResource("state-graph.dot");
String expectedStateGraphDot = Resources.toString(stateGraphDotFileUrl, StandardCharsets.UTF_8);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ModularXmppClientToServerConnectionTool.printStateGraph(pw, false);
String currentStateGraphDot = sw.toString();
@SuppressWarnings("serial") DOTImporter<String, DefaultEdge> dotImporter = new DOTImporter<>((id, attributes) -> id, (from, to, label, attributes) -> {
return new DefaultEdge() {
@Override
public int hashCode() {
return HashCode.builder().append(getSource()).append(getTarget()).build();
}
@Override
public boolean equals(Object other) {
return EqualsUtil.equals(this, other, (b, o) -> b.append(getSource(), o.getSource()).append(getTarget(), o.getTarget()));
}
};
});
DirectedPseudograph<String, DefaultEdge> currentStateGraph = new DirectedPseudograph<>(DefaultEdge.class);
DirectedPseudograph<String, DefaultEdge> expectedStateGraph = new DirectedPseudograph<>(DefaultEdge.class);
dotImporter.importGraph(expectedStateGraph, new StringReader(expectedStateGraphDot));
dotImporter.importGraph(currentStateGraph, new StringReader(currentStateGraphDot));
assertEquals(expectedStateGraph, currentStateGraph);
}
use of org.jgrapht.graph.DirectedPseudograph in project admin-console-beta by connexta.
the class CreateServiceDependencyGraph method createServiceDepsGraph.
private DirectedGraph<BundleField, DependencyEdge<ServiceReferenceField>> createServiceDepsGraph(List<BundleField> bundles) {
DirectedGraph graph = new DirectedPseudograph<>(ServiceReferenceField.class);
bundles.forEach(graph::addVertex);
bundles.forEach(bundle -> populateGraphWithServices(bundle, graph, bundles));
return graph;
}
use of org.jgrapht.graph.DirectedPseudograph in project admin-console-beta by connexta.
the class CreatePackageDependencyGraph method createPkgDependencyGraph.
private DirectedGraph<BundleField, DependencyEdge<PackageField>> createPkgDependencyGraph() {
DirectedGraph graph = new DirectedPseudograph<>(ServiceReferenceField.class);
List<BundleField> allBundles = bundleUtils.getAllBundleFields();
allBundles.forEach(graph::addVertex);
allBundles.forEach(bundle -> createEdgesFromPkgs(bundle, graph, allBundles));
return graph;
}
Aggregations