@Test public void sort() { Graph g = new Graph(2); g.addAtom(mock(Atom.class)); g.addAtom(mock(Atom.class)); g.addAtom(mock(Atom.class)); g.addAtom(mock(Atom.class)); g.addEdge(new Edge(3, 2, Bond.IMPLICIT)); g.addEdge(new Edge(1, 2, Bond.IMPLICIT)); g.addEdge(new Edge(0, 3, Bond.IMPLICIT)); g.addEdge(new Edge(0, 1, Bond.IMPLICIT)); assertThat(g.edges(0), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(0, 3, Bond.IMPLICIT), new Edge(0, 1, Bond.IMPLICIT)))); assertThat(g.edges(1), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(1, 2, Bond.IMPLICIT), new Edge(1, 0, Bond.IMPLICIT)))); assertThat(g.edges(2), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(2, 3, Bond.IMPLICIT), new Edge(2, 1, Bond.IMPLICIT)))); assertThat(g.edges(3), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(3, 2, Bond.IMPLICIT), new Edge(3, 0, Bond.IMPLICIT)))); g.sort(new Graph.CanOrderFirst()); assertThat(g.edges(0), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(0, 1, Bond.IMPLICIT), new Edge(0, 3, Bond.IMPLICIT)))); assertThat(g.edges(1), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(1, 0, Bond.IMPLICIT), new Edge(1, 2, Bond.IMPLICIT)))); assertThat(g.edges(2), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(2, 1, Bond.IMPLICIT), new Edge(2, 3, Bond.IMPLICIT)))); assertThat(g.edges(3), CoreMatchers .<List<Edge>>is(Arrays.asList(new Edge(3, 0, Bond.IMPLICIT), new Edge(3, 2, Bond.IMPLICIT)))); }
public Graph sort(EdgeComparator comparator) { for (int u = 0; u < order; u++) { final Edge[] es = edges[u]; final int deg = degrees[u]; for (int i = 1; i < deg; i++) { int j = i - 1; Edge e = es[i]; while (j >= 0 && comparator.less(this, u, e, es[j])) { es[j + 1] = es[j--]; } es[j + 1] = e; } } return this; }
Graph { public Graph sort(EdgeComparator comparator) { for (int u = 0; u < order; u++) { final Edge[] es = edges[u]; final int deg = degrees[u]; for (int i = 1; i < deg; i++) { int j = i - 1; Edge e = es[i]; while (j >= 0 && comparator.less(this, u, e, es[j])) { es[j + 1] = es[j--]; } es[j + 1] = e; } } return this; } }
Graph { public Graph sort(EdgeComparator comparator) { for (int u = 0; u < order; u++) { final Edge[] es = edges[u]; final int deg = degrees[u]; for (int i = 1; i < deg; i++) { int j = i - 1; Edge e = es[i]; while (j >= 0 && comparator.less(this, u, e, es[j])) { es[j + 1] = es[j--]; } es[j + 1] = e; } } return this; } Graph(int expSize);   Graph(Graph org); }
Graph { public Graph sort(EdgeComparator comparator) { for (int u = 0; u < order; u++) { final Edge[] es = edges[u]; final int deg = degrees[u]; for (int i = 1; i < deg; i++) { int j = i - 1; Edge e = es[i]; while (j >= 0 && comparator.less(this, u, e, es[j])) { es[j + 1] = es[j--]; } es[j + 1] = e; } } return this; } Graph(int expSize);   Graph(Graph org); Atom atom(int i); int degree(int u); List<Edge> edges(int u); int[] neighbors(int u); boolean adjacent(int u, int v); int implHCount(int u); Edge edge(int u, int v); Edge edgeAt(int u, int j); Topology topologyOf(int u); Configuration configurationOf(int u); int order(); int size(); static Graph fromSmiles(String smi); static Graph parse(String smi, boolean strict, Set<String> warnings); String toSmiles(); String toSmiles(int[] visitedAt); Graph aromatic(); Graph resonate(); Graph kekule(); boolean assignable(); Graph permute(int[] p); Iterable<Atom> atoms(); Iterable<Edge> edges(); int getFlags(final int mask); int getFlags(); void setTitle(String title); String getTitle(); Graph sort(EdgeComparator comparator); }
Graph { public Graph sort(EdgeComparator comparator) { for (int u = 0; u < order; u++) { final Edge[] es = edges[u]; final int deg = degrees[u]; for (int i = 1; i < deg; i++) { int j = i - 1; Edge e = es[i]; while (j >= 0 && comparator.less(this, u, e, es[j])) { es[j + 1] = es[j--]; } es[j + 1] = e; } } return this; } Graph(int expSize);   Graph(Graph org); Atom atom(int i); int degree(int u); List<Edge> edges(int u); int[] neighbors(int u); boolean adjacent(int u, int v); int implHCount(int u); Edge edge(int u, int v); Edge edgeAt(int u, int j); Topology topologyOf(int u); Configuration configurationOf(int u); int order(); int size(); static Graph fromSmiles(String smi); static Graph parse(String smi, boolean strict, Set<String> warnings); String toSmiles(); String toSmiles(int[] visitedAt); Graph aromatic(); Graph resonate(); Graph kekule(); boolean assignable(); Graph permute(int[] p); Iterable<Atom> atoms(); Iterable<Edge> edges(); int getFlags(final int mask); int getFlags(); void setTitle(String title); String getTitle(); Graph sort(EdgeComparator comparator); static final int HAS_AROM; static final int HAS_ATM_STRO; static final int HAS_EXT_STRO; static final int HAS_BND_STRO; static final int HAS_STRO; }