Skip to content

Instantly share code, notes, and snippets.

@johnmay
Created November 23, 2012 18:53
Show Gist options
  • Select an option

  • Save johnmay/4136826 to your computer and use it in GitHub Desktop.

Select an option

Save johnmay/4136826 to your computer and use it in GitHub Desktop.
Iteration
private int iterate(IAtomContainer container) {
int total = 0;
for (int d = 0; d < 8; d++) {
for (IAtom atom : container.atoms()) {
for (IBond bond : container.getConnectedBondsList(atom)) {
IAtom other = bond.getConnectedAtom(atom);
total += other.getAtomicNumber();
}
}
}
return total;
}
private int iterate(Graph graph) {
int total = 0;
for (int d = 0; d < 8; d++) {
for (int i = 0; i < graph.n(); i++) {
for (int j : graph.neighbors(i)) {
total += graph.getVertexValue(j).getAtomicNumber();
}
}
}
return total;
}
private int iterate(ConnectionMatrix cm) {
byte [][] graph = cm.graph;
int total = 0;
for (int d = 0; d < 8; d++) {
for (int i = 0; i < graph.length; i++) {
for (int j = 0; j < graph[i].length; j++) {
if(graph[i][j] != 0)
total += cm.atoms[j].getAtomicNumber();
}
}
}
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment