Skip to content

Commit

Permalink
Resolvers review comments - also ensure correct copyright.
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jun 10, 2013
1 parent 98b1b5f commit 98f9678
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 45 deletions.
27 changes: 27 additions & 0 deletions src/main/org/openscience/cdk/graph/BitMatrix.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/
package org.openscience.cdk.graph;

import org.openscience.cdk.annotations.TestClass;
Expand Down Expand Up @@ -176,6 +199,10 @@ private int eliminate(int x, int y) {
swap(i, y);

// xor row with all vectors that have x set
// note: rows above y are not touched, this isn't an issue in
// it's current use (cycle basis) as we only care about
// new additions being independent. However starting from
// j = 0 allows you to change this but of course is slower.
for (int j = y + 1; j < m; j++)
if (rows[j].get(x))
rows[j] = xor(rows[j], rows[y]);
Expand Down
33 changes: 28 additions & 5 deletions src/main/org/openscience/cdk/graph/EssentialCycles.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/
package org.openscience.cdk.graph;

import org.openscience.cdk.annotations.TestClass;
Expand All @@ -21,11 +44,11 @@
*
* @author John May
* @cdk.module core
* @cdk.keyword Essential Rings
* @cdk.keyword Essential Cycles
* @cdk.keyword Graph
* @cdk.keyword Cycles
* @cdk.keyword Rings
* @cdk.keyword essential rings
* @cdk.keyword essential cycles
* @cdk.keyword graph
* @cdk.keyword cycles
* @cdk.keyword rings
* @see RelevantCycles
* @see MinimumCycleBasis
* @see org.openscience.cdk.ringsearch.SSSRFinder#findEssentialRings()
Expand Down
14 changes: 7 additions & 7 deletions src/main/org/openscience/cdk/graph/GraphUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand All @@ -20,7 +21,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.graph;

import org.openscience.cdk.annotations.TestClass;
Expand Down Expand Up @@ -123,10 +123,10 @@ public static int[][] subgraph(int[][] graph, int[] include) {
int n = graph.length;
int m = include.length;

// lookup from graph to subgraph
int[] lookup = new int[n];
// mapping from vertex in 'graph' to 'subgraph'
int[] mapping = new int[n];
for (int i = 0; i < m; i++) {
lookup[include[i]] = i + 1;
mapping[include[i]] = i + 1;
}

// initialise the subgraph
Expand All @@ -137,12 +137,12 @@ public static int[][] subgraph(int[][] graph, int[] include) {
// vertices p and q. If p or q is less then 0 then it is not
// in the subgraph
for (int v = 0; v < n; v++) {
int p = lookup[v] - 1;
int p = mapping[v] - 1;
if (p < 0)
continue;

for (int w : graph[v]) {
int q = lookup[w] - 1;
int q = mapping[w] - 1;
if (q < 0)
continue;
if (degree[p] == subgraph[p].length)
Expand Down
3 changes: 2 additions & 1 deletion src/main/org/openscience/cdk/graph/GreedyBasis.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down
26 changes: 23 additions & 3 deletions src/main/org/openscience/cdk/graph/InitialCycles.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand All @@ -20,7 +21,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.graph;

import org.openscience.cdk.annotations.TestClass;
Expand Down Expand Up @@ -66,7 +66,15 @@ final class InitialCycles {
private final Map<Edge, Integer> edgeToIndex;
private final List<Edge> edges;

/** The degree indicates the start count for the key-value counting. */
/**
* Initial array size for 'ordering()'. This method sorts vertices by degree
* by counting how many of each degree there is then putting values in place
* directly. This is known as key-value counting and is used in radix
* sorts.
*
* @see <a href="https://en.wikipedia.org/wiki/Radix_sort#Least_significant_digit_radix_sorts">Radix
* Sort</a>
*/
private final static int DEFAULT_DEGREE = 4;

/**
Expand Down Expand Up @@ -499,6 +507,12 @@ int length() {
}
}

/**
* An even cycle is formed from two shortest paths of the same length
* and 'two' edges to a common vertex. The cycle formed by these is
* even, 2n + 2 = even.
* @see #compute()
*/
class EvenCycle extends Cycle {
int p, q, y;

Expand Down Expand Up @@ -537,6 +551,12 @@ class EvenCycle extends Cycle {
}
}

/**
* An odd cycle is formed from two shortest paths of the same length
* and 'one' edge to a common vertex. The cycle formed by these is odd,
* 2n + 1 = odd.
* @see #compute()
*/
class OddCycle extends Cycle {
int y, z;

Expand Down
54 changes: 39 additions & 15 deletions src/main/org/openscience/cdk/graph/MinimumCycleBasis.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/
package org.openscience.cdk.graph;

import org.openscience.cdk.annotations.TestClass;
Expand All @@ -22,26 +45,27 @@
* with MCB although traditionally their meaning was different {@cdk.cite
* Berger04}. Although the MCB can be used to generate all other cycles of a
* graph it may not be unique. A compound with a bridged ring system, such as <a
* href="http://bit.ly/11sBxYr"><i>3-quinuclidinol</i></a>, has three equally
* valid minimum cycle bases. From any two six member rings the third ring can
* be generated by &oplus;-sum (xoring) their edges. As there may be more than
* one MCB it should not be used as a <i>unique</i> descriptor. The smallest
* (but potentially exponential) <i>unique</i> set of short cycles which
* generates the cycle space is the union of all minimum cycle bases. This set
* is known as the {@link RelevantCycles}. The intersect of all minimum cycle
* bases ({@link EssentialCycles}) is also unique. Although the number of {@link
* href="http://www.ebi.ac.uk/chebi/searchId.do?chebiId=CHEBI:115239">
* <i>3-quinuclidinol</i></a>, has three equally valid minimum cycle bases. From
* any two six member rings the third ring can be generated by &oplus;-sum
* (xoring) their edges. As there may be more than one MCB it should not be used
* as a <i>unique</i> descriptor. The smallest (but potentially exponential)
* <i>unique</i> set of short cycles which generates the cycle space is the
* union of all minimum cycle bases. This set is known as the {@link
* RelevantCycles}. The intersect of all minimum cycle bases ({@link
* EssentialCycles}) is also unique. Although the number of {@link
* EssentialCycles} is polynomial it can not always be used to generate the
* cycle space.
*
* @author John May
* @cdk.module core
* @cdk.keyword SSSR
* @cdk.keyword Smallest Set of Smallest Rings
* @cdk.keyword MCB
* @cdk.keyword Minimum Cycle Basis
* @cdk.keyword Cycle
* @cdk.keyword Ring
* @cdk.keyword Ring Perception
* @cdk.keyword sssr
* @cdk.keyword smallest set of smallest rings
* @cdk.keyword mcb
* @cdk.keyword minimum cycle basis
* @cdk.keyword cycle
* @cdk.keyword ring
* @cdk.keyword ring perception
* @see RelevantCycles
* @see org.openscience.cdk.ringsearch.SSSRFinder#findSSSR()
* @see <a href="http://en.wikipedia.org/wiki/Cycle_space">Cycle Basis</a>
Expand Down
15 changes: 8 additions & 7 deletions src/main/org/openscience/cdk/graph/RelevantCycles.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down Expand Up @@ -74,13 +75,13 @@
*
* @author John May
* @cdk.module core
* @cdk.keyword Relevant Cycles
* @cdk.keyword Relevant Rings
* @cdk.keyword relevant cycles
* @cdk.keyword relevant rings
* @cdk.keyword R(G)
* @cdk.keyword Union of all Minimum Cycles Bases
* @cdk.keyword Cycle
* @cdk.keyword Ring
* @cdk.keyword Ring Perception
* @cdk.keyword union of all minimum cycles bases
* @cdk.keyword cycle
* @cdk.keyword ring
* @cdk.keyword ring perception
* @cdk.githash
* @see org.openscience.cdk.ringsearch.RingSearch
* @see org.openscience.cdk.ringsearch.SSSRFinder#findRelevantRings()
Expand Down
3 changes: 2 additions & 1 deletion src/test/org/openscience/cdk/graph/BitMatrixTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down
4 changes: 2 additions & 2 deletions src/test/org/openscience/cdk/graph/EssentialCyclesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand All @@ -20,7 +21,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.graph;

import org.junit.Test;
Expand Down
24 changes: 24 additions & 0 deletions src/test/org/openscience/cdk/graph/GraphUtilTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/
package org.openscience.cdk.graph;

import org.junit.Test;
Expand Down Expand Up @@ -202,6 +225,7 @@ public void testToAdjList_Null() throws Exception {

/**
* 2,2-dimethylpropane
* @cdk.inchi InChI=1S/C5H12/c1-5(2,3)4/h1-4H3
*/
private static IAtomContainer simple() {

Expand Down
3 changes: 2 additions & 1 deletion src/test/org/openscience/cdk/graph/GreedyBasisTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down
4 changes: 2 additions & 2 deletions src/test/org/openscience/cdk/graph/InitialCyclesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
* Copyright (c) 2013 European Bioinformatics Institute (EMBL-EBI)
* John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand All @@ -20,7 +21,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.graph;

import org.junit.Test;
Expand Down

0 comments on commit 98f9678

Please sign in to comment.