Created
November 23, 2012 18:53
-
-
Save johnmay/4136826 to your computer and use it in GitHub Desktop.
Iteration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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