use of org.openscience.cdk.graph.BiconnectivityInspector in project Smiles2Monomers by yoann-dufresne.
the class Biconnected method createBiconnectedComponents.
/*
* Function to create biconned components
*/
@SuppressWarnings("unchecked")
public static List<Biconnected> createBiconnectedComponents(UndirectedGraph g) {
BiconnectivityInspector bi = new BiconnectivityInspector(g);
List<Set<UndirectedEdge>> biconnecteds = bi.biconnectedSets();
List<Biconnected> bcs = new ArrayList<>();
for (Set<UndirectedEdge> edges : biconnecteds) {
HashSet<Atom> vertices = new HashSet<>();
Iterator<UndirectedEdge> i = edges.iterator();
while (i.hasNext()) {
UndirectedEdge e = i.next();
vertices.add((Atom) e.getSource());
vertices.add((Atom) e.getTarget());
}
Biconnected sg = new Biconnected(g, vertices, edges);
bcs.add(sg);
}
return bcs;
}
Aggregations